@mui/x-date-pickers 7.6.1 → 7.7.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/AdapterDayjs/AdapterDayjs.js +5 -1
- package/CHANGELOG.md +147 -0
- package/DateCalendar/DateCalendar.js +3 -3
- package/DateCalendar/DateCalendar.types.d.ts +4 -4
- package/DateCalendar/DayCalendar.d.ts +3 -4
- package/DateCalendar/DayCalendar.js +11 -11
- package/DateTimePicker/DateTimePickerToolbar.js +59 -49
- package/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +11 -1
- package/MonthCalendar/MonthCalendar.js +21 -7
- package/MonthCalendar/MonthCalendar.types.d.ts +25 -0
- package/MonthCalendar/PickersMonth.d.ts +4 -0
- package/MonthCalendar/PickersMonth.js +38 -21
- package/MonthCalendar/index.d.ts +1 -1
- package/PickersCalendarHeader/PickersCalendarHeader.types.d.ts +1 -1
- package/PickersLayout/PickersLayout.d.ts +1 -3
- package/PickersLayout/PickersLayout.js +30 -9
- package/PickersLayout/PickersLayout.types.d.ts +8 -4
- package/PickersTextField/PickersInputBase/PickersInputBase.d.ts +1 -0
- package/PickersTextField/PickersInputBase/PickersInputBase.js +14 -6
- package/TimePicker/TimePickerToolbar.js +21 -18
- package/YearCalendar/PickersYear.d.ts +3 -0
- package/YearCalendar/PickersYear.js +34 -22
- package/YearCalendar/YearCalendar.js +21 -7
- package/YearCalendar/YearCalendar.types.d.ts +25 -0
- package/YearCalendar/index.d.ts +1 -1
- package/index.js +1 -1
- package/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +5 -5
- package/internals/components/PickersToolbarButton.d.ts +1 -1
- package/internals/hooks/useField/buildSectionsFromFormat.d.ts +1 -1
- package/internals/hooks/useField/buildSectionsFromFormat.js +3 -3
- package/internals/hooks/useField/useField.js +3 -4
- package/internals/hooks/useField/useField.types.d.ts +2 -2
- package/internals/hooks/useField/useField.utils.d.ts +1 -1
- package/internals/hooks/useField/useField.utils.js +6 -5
- package/internals/hooks/useField/useFieldState.js +6 -7
- package/internals/hooks/useField/useFieldV6TextField.d.ts +1 -1
- package/internals/hooks/useField/useFieldV6TextField.js +10 -11
- package/internals/hooks/usePicker/usePickerLayoutProps.d.ts +1 -0
- package/internals/hooks/usePicker/usePickerLayoutProps.js +3 -0
- package/locales/faIR.js +19 -22
- package/locales/koKR.js +2 -2
- package/modern/AdapterDayjs/AdapterDayjs.js +5 -1
- package/modern/DateCalendar/DateCalendar.js +3 -3
- package/modern/DateCalendar/DayCalendar.js +11 -11
- package/modern/DateTimePicker/DateTimePickerToolbar.js +59 -49
- package/modern/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +11 -1
- package/modern/MonthCalendar/MonthCalendar.js +21 -7
- package/modern/MonthCalendar/PickersMonth.js +38 -21
- package/modern/PickersLayout/PickersLayout.js +30 -9
- package/modern/PickersTextField/PickersInputBase/PickersInputBase.js +14 -6
- package/modern/TimePicker/TimePickerToolbar.js +21 -18
- package/modern/YearCalendar/PickersYear.js +34 -22
- package/modern/YearCalendar/YearCalendar.js +21 -7
- package/modern/index.js +1 -1
- package/modern/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +5 -5
- package/modern/internals/hooks/useField/buildSectionsFromFormat.js +3 -3
- package/modern/internals/hooks/useField/useField.js +3 -4
- package/modern/internals/hooks/useField/useField.utils.js +6 -5
- package/modern/internals/hooks/useField/useFieldState.js +6 -7
- package/modern/internals/hooks/useField/useFieldV6TextField.js +10 -11
- package/modern/internals/hooks/usePicker/usePickerLayoutProps.js +3 -0
- package/modern/locales/faIR.js +19 -22
- package/modern/locales/koKR.js +2 -2
- package/node/AdapterDayjs/AdapterDayjs.js +5 -1
- package/node/DateCalendar/DateCalendar.js +3 -3
- package/node/DateCalendar/DayCalendar.js +10 -10
- package/node/DateTimePicker/DateTimePickerToolbar.js +58 -48
- package/node/DesktopDateTimePicker/DesktopDateTimePickerLayout.js +11 -1
- package/node/MonthCalendar/MonthCalendar.js +21 -7
- package/node/MonthCalendar/PickersMonth.js +40 -23
- package/node/PickersLayout/PickersLayout.js +30 -9
- package/node/PickersTextField/PickersInputBase/PickersInputBase.js +14 -6
- package/node/TimePicker/TimePickerToolbar.js +20 -17
- package/node/YearCalendar/PickersYear.js +34 -22
- package/node/YearCalendar/YearCalendar.js +21 -7
- package/node/index.js +1 -1
- package/node/internals/components/PickersArrowSwitcher/PickersArrowSwitcher.js +4 -4
- package/node/internals/hooks/useField/buildSectionsFromFormat.js +3 -3
- package/node/internals/hooks/useField/useField.js +3 -4
- package/node/internals/hooks/useField/useField.utils.js +6 -5
- package/node/internals/hooks/useField/useFieldState.js +6 -7
- package/node/internals/hooks/useField/useFieldV6TextField.js +10 -11
- package/node/internals/hooks/usePicker/usePickerLayoutProps.js +3 -0
- package/node/locales/faIR.js +19 -22
- package/node/locales/koKR.js +2 -2
- package/package.json +2 -2
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
2
2
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
-
const _excluded = ["autoFocus", "children", "disabled", "selected", "value", "tabIndex", "onClick", "onKeyDown", "onFocus", "onBlur", "aria-current", "aria-label", "monthsPerRow"];
|
|
3
|
+
const _excluded = ["autoFocus", "className", "children", "disabled", "selected", "value", "tabIndex", "onClick", "onKeyDown", "onFocus", "onBlur", "aria-current", "aria-label", "monthsPerRow", "slots", "slotProps"];
|
|
4
4
|
import * as React from 'react';
|
|
5
|
+
import clsx from 'clsx';
|
|
5
6
|
import { styled, alpha, useThemeProps } from '@mui/material/styles';
|
|
6
|
-
import {
|
|
7
|
+
import { useSlotProps } from '@mui/base/utils';
|
|
8
|
+
import composeClasses from '@mui/utils/composeClasses';
|
|
9
|
+
import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
|
|
7
10
|
import { getPickersMonthUtilityClass, pickersMonthClasses } from './pickersMonthClasses';
|
|
8
11
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
12
|
const useUtilityClasses = ownerState => {
|
|
@@ -36,7 +39,7 @@ const PickersMonthRoot = styled('div', {
|
|
|
36
39
|
}
|
|
37
40
|
}]
|
|
38
41
|
});
|
|
39
|
-
const
|
|
42
|
+
const MonthCalendarButton = styled('button', {
|
|
40
43
|
name: 'MuiPickersMonth',
|
|
41
44
|
slot: 'MonthButton',
|
|
42
45
|
overridesResolver: (_, styles) => [styles.monthButton, {
|
|
@@ -89,6 +92,7 @@ export const PickersMonth = /*#__PURE__*/React.memo(function PickersMonth(inProp
|
|
|
89
92
|
});
|
|
90
93
|
const {
|
|
91
94
|
autoFocus,
|
|
95
|
+
className,
|
|
92
96
|
children,
|
|
93
97
|
disabled,
|
|
94
98
|
selected,
|
|
@@ -101,35 +105,48 @@ export const PickersMonth = /*#__PURE__*/React.memo(function PickersMonth(inProp
|
|
|
101
105
|
'aria-current': ariaCurrent,
|
|
102
106
|
'aria-label': ariaLabel
|
|
103
107
|
// We don't want to forward this prop to the root element
|
|
108
|
+
,
|
|
109
|
+
|
|
110
|
+
slots,
|
|
111
|
+
slotProps
|
|
104
112
|
} = props,
|
|
105
113
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
106
114
|
const ref = React.useRef(null);
|
|
107
115
|
const classes = useUtilityClasses(props);
|
|
116
|
+
|
|
117
|
+
// We can't forward the `autoFocus` to the button because it is a native button, not a MUI Button
|
|
108
118
|
useEnhancedEffect(() => {
|
|
109
119
|
if (autoFocus) {
|
|
120
|
+
// `ref.current` being `null` would be a bug in MUI.
|
|
110
121
|
ref.current?.focus();
|
|
111
122
|
}
|
|
112
123
|
}, [autoFocus]);
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
disabled
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
124
|
+
const MonthButton = slots?.monthButton ?? MonthCalendarButton;
|
|
125
|
+
const monthButtonProps = useSlotProps({
|
|
126
|
+
elementType: MonthButton,
|
|
127
|
+
externalSlotProps: slotProps?.monthButton,
|
|
128
|
+
additionalProps: {
|
|
129
|
+
children,
|
|
130
|
+
disabled,
|
|
131
|
+
tabIndex,
|
|
132
|
+
ref,
|
|
133
|
+
type: 'button',
|
|
134
|
+
role: 'radio',
|
|
135
|
+
'aria-current': ariaCurrent,
|
|
136
|
+
'aria-checked': selected,
|
|
137
|
+
'aria-label': ariaLabel,
|
|
126
138
|
onClick: event => onClick(event, value),
|
|
127
139
|
onKeyDown: event => onKeyDown(event, value),
|
|
128
140
|
onFocus: event => onFocus(event, value),
|
|
129
|
-
onBlur: event => onBlur(event, value)
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
141
|
+
onBlur: event => onBlur(event, value)
|
|
142
|
+
},
|
|
143
|
+
ownerState: props,
|
|
144
|
+
className: classes.monthButton
|
|
145
|
+
});
|
|
146
|
+
return /*#__PURE__*/_jsx(PickersMonthRoot, _extends({
|
|
147
|
+
className: clsx(classes.root, className),
|
|
148
|
+
ownerState: props
|
|
149
|
+
}, other, {
|
|
150
|
+
children: /*#__PURE__*/_jsx(MonthButton, _extends({}, monthButtonProps))
|
|
134
151
|
}));
|
|
135
152
|
});
|
package/MonthCalendar/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { MonthCalendar } from './MonthCalendar';
|
|
2
|
-
export type { MonthCalendarProps } from './MonthCalendar.types';
|
|
2
|
+
export type { MonthCalendarProps, MonthCalendarSlots, MonthCalendarSlotProps, } from './MonthCalendar.types';
|
|
3
3
|
export { monthCalendarClasses, getMonthCalendarUtilityClass } from './monthCalendarClasses';
|
|
4
4
|
export type { MonthCalendarClasses, MonthCalendarClassKey } from './monthCalendarClasses';
|
|
5
5
|
export { pickersMonthClasses } from './pickersMonthClasses';
|
|
@@ -15,7 +15,7 @@ export interface PickersCalendarHeaderSlots extends PickersArrowSwitcherSlots {
|
|
|
15
15
|
*/
|
|
16
16
|
switchViewButton?: React.ElementType;
|
|
17
17
|
/**
|
|
18
|
-
* Icon displayed in the SwitchViewButton. Rotated by 180° when the open view is
|
|
18
|
+
* Icon displayed in the SwitchViewButton. Rotated by 180° when the open view is "year".
|
|
19
19
|
* @default ArrowDropDown
|
|
20
20
|
*/
|
|
21
21
|
switchViewIcon?: React.ElementType;
|
|
@@ -3,9 +3,7 @@ import { PickersLayoutProps } from './PickersLayout.types';
|
|
|
3
3
|
import { DateOrTimeViewWithMeridiem } from '../internals/models';
|
|
4
4
|
import { PickerValidDate } from '../models';
|
|
5
5
|
export declare const PickersLayoutRoot: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme> & {
|
|
6
|
-
ownerState:
|
|
7
|
-
isLandscape: boolean;
|
|
8
|
-
};
|
|
6
|
+
ownerState: PickersLayoutProps<any, any, any>;
|
|
9
7
|
}, Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof React.ClassAttributes<HTMLDivElement> | keyof React.HTMLAttributes<HTMLDivElement>>, {}>;
|
|
10
8
|
export declare const PickersLayoutContentWrapper: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof React.ClassAttributes<HTMLDivElement> | keyof React.HTMLAttributes<HTMLDivElement>>, {}>;
|
|
11
9
|
/**
|
|
@@ -21,9 +21,7 @@ export const PickersLayoutRoot = styled('div', {
|
|
|
21
21
|
name: 'MuiPickersLayout',
|
|
22
22
|
slot: 'Root',
|
|
23
23
|
overridesResolver: (props, styles) => styles.root
|
|
24
|
-
})(
|
|
25
|
-
theme
|
|
26
|
-
}) => ({
|
|
24
|
+
})({
|
|
27
25
|
display: 'grid',
|
|
28
26
|
gridAutoColumns: 'max-content auto max-content',
|
|
29
27
|
gridAutoRows: 'max-content auto max-content',
|
|
@@ -37,7 +35,7 @@ export const PickersLayoutRoot = styled('div', {
|
|
|
37
35
|
},
|
|
38
36
|
style: {
|
|
39
37
|
[`& .${pickersLayoutClasses.toolbar}`]: {
|
|
40
|
-
gridColumn:
|
|
38
|
+
gridColumn: 1,
|
|
41
39
|
gridRow: '2 / 3'
|
|
42
40
|
},
|
|
43
41
|
[`.${pickersLayoutClasses.shortcuts}`]: {
|
|
@@ -45,6 +43,16 @@ export const PickersLayoutRoot = styled('div', {
|
|
|
45
43
|
gridRow: 1
|
|
46
44
|
}
|
|
47
45
|
}
|
|
46
|
+
}, {
|
|
47
|
+
props: {
|
|
48
|
+
isLandscape: true,
|
|
49
|
+
isRtl: true
|
|
50
|
+
},
|
|
51
|
+
style: {
|
|
52
|
+
[`& .${pickersLayoutClasses.toolbar}`]: {
|
|
53
|
+
gridColumn: 3
|
|
54
|
+
}
|
|
55
|
+
}
|
|
48
56
|
}, {
|
|
49
57
|
props: {
|
|
50
58
|
isLandscape: false
|
|
@@ -55,12 +63,22 @@ export const PickersLayoutRoot = styled('div', {
|
|
|
55
63
|
gridRow: 1
|
|
56
64
|
},
|
|
57
65
|
[`& .${pickersLayoutClasses.shortcuts}`]: {
|
|
58
|
-
gridColumn:
|
|
66
|
+
gridColumn: 1,
|
|
59
67
|
gridRow: '2 / 3'
|
|
60
68
|
}
|
|
61
69
|
}
|
|
70
|
+
}, {
|
|
71
|
+
props: {
|
|
72
|
+
isLandscape: false,
|
|
73
|
+
isRtl: true
|
|
74
|
+
},
|
|
75
|
+
style: {
|
|
76
|
+
[`& .${pickersLayoutClasses.shortcuts}`]: {
|
|
77
|
+
gridColumn: 3
|
|
78
|
+
}
|
|
79
|
+
}
|
|
62
80
|
}]
|
|
63
|
-
})
|
|
81
|
+
});
|
|
64
82
|
export const PickersLayoutContentWrapper = styled('div', {
|
|
65
83
|
name: 'MuiPickersLayout',
|
|
66
84
|
slot: 'ContentWrapper',
|
|
@@ -100,13 +118,12 @@ const PickersLayout = function PickersLayout(inProps) {
|
|
|
100
118
|
ref,
|
|
101
119
|
wrapperVariant
|
|
102
120
|
} = props;
|
|
103
|
-
const
|
|
104
|
-
const classes = useUtilityClasses(ownerState);
|
|
121
|
+
const classes = useUtilityClasses(props);
|
|
105
122
|
return /*#__PURE__*/_jsxs(PickersLayoutRoot, {
|
|
106
123
|
ref: ref,
|
|
107
124
|
sx: sx,
|
|
108
125
|
className: clsx(className, classes.root),
|
|
109
|
-
ownerState:
|
|
126
|
+
ownerState: props,
|
|
110
127
|
children: [isLandscape ? shortcuts : toolbar, isLandscape ? toolbar : shortcuts, /*#__PURE__*/_jsx(PickersLayoutContentWrapper, {
|
|
111
128
|
className: classes.contentWrapper,
|
|
112
129
|
children: wrapperVariant === 'desktop' ? /*#__PURE__*/_jsxs(React.Fragment, {
|
|
@@ -130,6 +147,10 @@ process.env.NODE_ENV !== "production" ? PickersLayout.propTypes = {
|
|
|
130
147
|
className: PropTypes.string,
|
|
131
148
|
disabled: PropTypes.bool,
|
|
132
149
|
isLandscape: PropTypes.bool.isRequired,
|
|
150
|
+
/**
|
|
151
|
+
* `true` if the application is in right-to-left direction.
|
|
152
|
+
*/
|
|
153
|
+
isRtl: PropTypes.bool.isRequired,
|
|
133
154
|
isValid: PropTypes.func.isRequired,
|
|
134
155
|
onAccept: PropTypes.func.isRequired,
|
|
135
156
|
onCancel: PropTypes.func.isRequired,
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { SxProps, Theme } from '@mui/material/styles';
|
|
3
3
|
import { SlotComponentProps } from '@mui/base/utils';
|
|
4
|
-
import { PickersActionBarProps } from '../PickersActionBar';
|
|
4
|
+
import { PickersActionBar, PickersActionBarProps } from '../PickersActionBar';
|
|
5
5
|
import { BaseToolbarProps, ExportedBaseToolbarProps } from '../internals/models/props/toolbar';
|
|
6
6
|
import { BaseTabsProps, ExportedBaseTabsProps } from '../internals/models/props/tabs';
|
|
7
7
|
import { UsePickerLayoutPropsResponseLayoutProps } from '../internals/hooks/usePicker/usePickerLayoutProps';
|
|
8
8
|
import { PickersLayoutClasses } from './pickersLayoutClasses';
|
|
9
9
|
import { DateOrTimeViewWithMeridiem, WrapperVariant } from '../internals/models/common';
|
|
10
10
|
import { PickersShortcutsProps } from '../PickersShortcuts';
|
|
11
|
-
import { ExportedPickersShortcutProps } from '../PickersShortcuts/PickersShortcuts';
|
|
11
|
+
import { ExportedPickersShortcutProps, PickersShortcuts } from '../PickersShortcuts/PickersShortcuts';
|
|
12
12
|
import { PickerValidDate } from '../models';
|
|
13
13
|
export interface ExportedPickersLayoutSlots<TValue, TDate extends PickerValidDate, TView extends DateOrTimeViewWithMeridiem> {
|
|
14
14
|
/**
|
|
@@ -37,11 +37,11 @@ export interface ExportedPickersLayoutSlotProps<TValue, TDate extends PickerVali
|
|
|
37
37
|
/**
|
|
38
38
|
* Props passed down to the action bar component.
|
|
39
39
|
*/
|
|
40
|
-
actionBar?: SlotComponentProps<
|
|
40
|
+
actionBar?: SlotComponentProps<typeof PickersActionBar, {}, PickersLayoutActionBarOwnerState<TValue, TDate, TView>>;
|
|
41
41
|
/**
|
|
42
42
|
* Props passed down to the shortcuts component.
|
|
43
43
|
*/
|
|
44
|
-
shortcuts?: SlotComponentProps<
|
|
44
|
+
shortcuts?: SlotComponentProps<typeof PickersShortcuts, {}, PickersShortcutsOwnerState<TValue>>;
|
|
45
45
|
/**
|
|
46
46
|
* Props passed down to the layoutRoot component.
|
|
47
47
|
*/
|
|
@@ -94,6 +94,10 @@ export interface PickersLayoutProps<TValue, TDate extends PickerValidDate, TView
|
|
|
94
94
|
* @default {}
|
|
95
95
|
*/
|
|
96
96
|
slotProps?: PickersLayoutSlotProps<TValue, TDate, TView>;
|
|
97
|
+
/**
|
|
98
|
+
* `true` if the application is in right-to-left direction.
|
|
99
|
+
*/
|
|
100
|
+
isRtl: boolean;
|
|
97
101
|
}
|
|
98
102
|
export interface SubComponents<TValue> {
|
|
99
103
|
toolbar: React.ReactElement<ExportedBaseToolbarProps> | null;
|
|
@@ -8,6 +8,7 @@ export declare const PickersInputBaseSectionsContainer: import("@emotion/styled"
|
|
|
8
8
|
ownerState: OwnerStateType;
|
|
9
9
|
}, {}, {}>;
|
|
10
10
|
interface OwnerStateType extends FormControlState, Omit<PickersInputBaseProps, keyof FormControlState> {
|
|
11
|
+
isRtl: boolean;
|
|
11
12
|
}
|
|
12
13
|
/**
|
|
13
14
|
* @ignore - internal component.
|
|
@@ -11,6 +11,7 @@ import composeClasses from '@mui/utils/composeClasses';
|
|
|
11
11
|
import capitalize from '@mui/utils/capitalize';
|
|
12
12
|
import { useSlotProps } from '@mui/base/utils';
|
|
13
13
|
import visuallyHidden from '@mui/utils/visuallyHidden';
|
|
14
|
+
import { useRtl } from '@mui/system/RtlProvider';
|
|
14
15
|
import { pickersInputBaseClasses, getPickersInputBaseUtilityClass } from './pickersInputBaseClasses';
|
|
15
16
|
import { Unstable_PickersSectionList as PickersSectionList, Unstable_PickersSectionListRoot as PickersSectionListRoot, Unstable_PickersSectionListSection as PickersSectionListSection, Unstable_PickersSectionListSectionSeparator as PickersSectionListSectionSeparator, Unstable_PickersSectionListSectionContent as PickersSectionListSectionContent } from '../../PickersSectionList';
|
|
16
17
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -47,7 +48,7 @@ export const PickersInputBaseSectionsContainer = styled(PickersSectionListRoot,
|
|
|
47
48
|
overridesResolver: (props, styles) => styles.sectionsContainer
|
|
48
49
|
})(({
|
|
49
50
|
theme
|
|
50
|
-
}) =>
|
|
51
|
+
}) => ({
|
|
51
52
|
padding: '4px 0 5px',
|
|
52
53
|
fontFamily: theme.typography.fontFamily,
|
|
53
54
|
fontSize: 'inherit',
|
|
@@ -60,11 +61,15 @@ export const PickersInputBaseSectionsContainer = styled(PickersSectionListRoot,
|
|
|
60
61
|
overflow: 'hidden',
|
|
61
62
|
letterSpacing: 'inherit',
|
|
62
63
|
// Baseline behavior
|
|
63
|
-
width: '182px'
|
|
64
|
-
}, theme.direction === 'rtl' && {
|
|
65
|
-
textAlign: 'right /*! @noflip */'
|
|
66
|
-
}, {
|
|
64
|
+
width: '182px',
|
|
67
65
|
variants: [{
|
|
66
|
+
props: {
|
|
67
|
+
isRtl: true
|
|
68
|
+
},
|
|
69
|
+
style: {
|
|
70
|
+
textAlign: 'right /*! @noflip */'
|
|
71
|
+
}
|
|
72
|
+
}, {
|
|
68
73
|
props: {
|
|
69
74
|
size: 'small'
|
|
70
75
|
},
|
|
@@ -195,6 +200,7 @@ const PickersInputBase = /*#__PURE__*/React.forwardRef(function PickersInputBase
|
|
|
195
200
|
const rootRef = React.useRef(null);
|
|
196
201
|
const handleRootRef = useForkRef(ref, rootRef);
|
|
197
202
|
const handleInputRef = useForkRef(inputProps?.ref, inputRef);
|
|
203
|
+
const isRtl = useRtl();
|
|
198
204
|
const muiFormControl = useFormControl();
|
|
199
205
|
if (!muiFormControl) {
|
|
200
206
|
throw new Error('MUI X: PickersInputBase should always be used inside a PickersTextField component');
|
|
@@ -223,7 +229,9 @@ const PickersInputBase = /*#__PURE__*/React.forwardRef(function PickersInputBase
|
|
|
223
229
|
muiFormControl.onFilled();
|
|
224
230
|
}
|
|
225
231
|
}, [muiFormControl, areAllSectionsEmpty]);
|
|
226
|
-
const ownerState = _extends({}, props, muiFormControl
|
|
232
|
+
const ownerState = _extends({}, props, muiFormControl, {
|
|
233
|
+
isRtl
|
|
234
|
+
});
|
|
227
235
|
const classes = useUtilityClasses(ownerState);
|
|
228
236
|
const InputRoot = slots?.root || PickersInputBaseRoot;
|
|
229
237
|
const inputRootProps = useSlotProps({
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
2
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
3
|
const _excluded = ["ampm", "ampmInClock", "value", "isLandscape", "onChange", "view", "onViewChange", "views", "disabled", "readOnly", "className"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import clsx from 'clsx';
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
7
|
-
import {
|
|
7
|
+
import { useRtl } from '@mui/system/RtlProvider';
|
|
8
|
+
import { styled, useThemeProps } from '@mui/material/styles';
|
|
8
9
|
import { unstable_composeClasses as composeClasses } from '@mui/utils';
|
|
9
10
|
import { PickersToolbarText } from '../internals/components/PickersToolbarText';
|
|
10
11
|
import { PickersToolbarButton } from '../internals/components/PickersToolbarButton';
|
|
@@ -17,14 +18,14 @@ import { formatMeridiem } from '../internals/utils/date-utils';
|
|
|
17
18
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
18
19
|
const useUtilityClasses = ownerState => {
|
|
19
20
|
const {
|
|
20
|
-
theme,
|
|
21
21
|
isLandscape,
|
|
22
|
-
classes
|
|
22
|
+
classes,
|
|
23
|
+
isRtl
|
|
23
24
|
} = ownerState;
|
|
24
25
|
const slots = {
|
|
25
26
|
root: ['root'],
|
|
26
27
|
separator: ['separator'],
|
|
27
|
-
hourMinuteLabel: ['hourMinuteLabel', isLandscape && 'hourMinuteLabelLandscape',
|
|
28
|
+
hourMinuteLabel: ['hourMinuteLabel', isLandscape && 'hourMinuteLabelLandscape', isRtl && 'hourMinuteLabelReverse'],
|
|
28
29
|
ampmSelection: ['ampmSelection', isLandscape && 'ampmLandscape'],
|
|
29
30
|
ampmLabel: ['ampmLabel']
|
|
30
31
|
};
|
|
@@ -51,16 +52,18 @@ const TimePickerToolbarHourMinuteLabel = styled('div', {
|
|
|
51
52
|
[`&.${timePickerToolbarClasses.hourMinuteLabelLandscape}`]: styles.hourMinuteLabelLandscape,
|
|
52
53
|
[`&.${timePickerToolbarClasses.hourMinuteLabelReverse}`]: styles.hourMinuteLabelReverse
|
|
53
54
|
}, styles.hourMinuteLabel]
|
|
54
|
-
})(
|
|
55
|
-
theme
|
|
56
|
-
}) => _extends({
|
|
55
|
+
})({
|
|
57
56
|
display: 'flex',
|
|
58
57
|
justifyContent: 'flex-end',
|
|
59
|
-
alignItems: 'flex-end'
|
|
60
|
-
}, theme.direction === 'rtl' && {
|
|
61
|
-
flexDirection: 'row-reverse'
|
|
62
|
-
}, {
|
|
58
|
+
alignItems: 'flex-end',
|
|
63
59
|
variants: [{
|
|
60
|
+
props: {
|
|
61
|
+
isRtl: true
|
|
62
|
+
},
|
|
63
|
+
style: {
|
|
64
|
+
flexDirection: 'row-reverse'
|
|
65
|
+
}
|
|
66
|
+
}, {
|
|
64
67
|
props: {
|
|
65
68
|
isLandscape: true
|
|
66
69
|
},
|
|
@@ -68,7 +71,7 @@ const TimePickerToolbarHourMinuteLabel = styled('div', {
|
|
|
68
71
|
marginTop: 'auto'
|
|
69
72
|
}
|
|
70
73
|
}]
|
|
71
|
-
})
|
|
74
|
+
});
|
|
72
75
|
const TimePickerToolbarAmPmSelection = styled('div', {
|
|
73
76
|
name: 'MuiTimePickerToolbar',
|
|
74
77
|
slot: 'AmPmSelection',
|
|
@@ -129,17 +132,17 @@ function TimePickerToolbar(inProps) {
|
|
|
129
132
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
130
133
|
const utils = useUtils();
|
|
131
134
|
const localeText = useLocaleText();
|
|
132
|
-
const
|
|
135
|
+
const isRtl = useRtl();
|
|
133
136
|
const showAmPmControl = Boolean(ampm && !ampmInClock && views.includes('hours'));
|
|
134
137
|
const {
|
|
135
138
|
meridiemMode,
|
|
136
139
|
handleMeridiemChange
|
|
137
140
|
} = useMeridiemMode(value, ampm, onChange);
|
|
138
141
|
const formatHours = time => ampm ? utils.format(time, 'hours12h') : utils.format(time, 'hours24h');
|
|
139
|
-
const ownerState = props
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
142
|
+
const ownerState = _extends({}, props, {
|
|
143
|
+
isRtl
|
|
144
|
+
});
|
|
145
|
+
const classes = useUtilityClasses(ownerState);
|
|
143
146
|
const separator = /*#__PURE__*/_jsx(TimePickerToolbarSeparator, {
|
|
144
147
|
tabIndex: -1,
|
|
145
148
|
value: ":",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { PickersYearClasses } from './pickersYearClasses';
|
|
3
|
+
import { YearCalendarSlotProps, YearCalendarSlots } from './YearCalendar.types';
|
|
3
4
|
export interface ExportedPickersYearProps {
|
|
4
5
|
classes?: Partial<PickersYearClasses>;
|
|
5
6
|
}
|
|
@@ -17,6 +18,8 @@ export interface PickersYearProps extends ExportedPickersYearProps {
|
|
|
17
18
|
value: number;
|
|
18
19
|
tabIndex: number;
|
|
19
20
|
yearsPerRow: 3 | 4;
|
|
21
|
+
slots?: YearCalendarSlots;
|
|
22
|
+
slotProps?: YearCalendarSlotProps;
|
|
20
23
|
}
|
|
21
24
|
/**
|
|
22
25
|
* @ignore - internal component.
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
2
2
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
-
const _excluded = ["autoFocus", "className", "children", "disabled", "selected", "value", "tabIndex", "onClick", "onKeyDown", "onFocus", "onBlur", "aria-current", "yearsPerRow"];
|
|
3
|
+
const _excluded = ["autoFocus", "className", "children", "disabled", "selected", "value", "tabIndex", "onClick", "onKeyDown", "onFocus", "onBlur", "aria-current", "yearsPerRow", "slots", "slotProps"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import clsx from 'clsx';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
6
|
+
import { styled, alpha, useThemeProps } from '@mui/material/styles';
|
|
7
|
+
import { useSlotProps } from '@mui/base/utils';
|
|
8
|
+
import composeClasses from '@mui/utils/composeClasses';
|
|
9
|
+
import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
|
|
8
10
|
import { getPickersYearUtilityClass, pickersYearClasses } from './pickersYearClasses';
|
|
9
11
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
12
|
const useUtilityClasses = ownerState => {
|
|
@@ -37,7 +39,7 @@ const PickersYearRoot = styled('div', {
|
|
|
37
39
|
}
|
|
38
40
|
}]
|
|
39
41
|
});
|
|
40
|
-
const
|
|
42
|
+
const YearCalendarButton = styled('button', {
|
|
41
43
|
name: 'MuiPickersYear',
|
|
42
44
|
slot: 'YearButton',
|
|
43
45
|
overridesResolver: (_, styles) => [styles.yearButton, {
|
|
@@ -102,37 +104,47 @@ export const PickersYear = /*#__PURE__*/React.memo(function PickersYear(inProps)
|
|
|
102
104
|
onBlur,
|
|
103
105
|
'aria-current': ariaCurrent
|
|
104
106
|
// We don't want to forward this prop to the root element
|
|
107
|
+
,
|
|
108
|
+
|
|
109
|
+
slots,
|
|
110
|
+
slotProps
|
|
105
111
|
} = props,
|
|
106
112
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
107
113
|
const ref = React.useRef(null);
|
|
108
114
|
const classes = useUtilityClasses(props);
|
|
109
115
|
|
|
110
116
|
// We can't forward the `autoFocus` to the button because it is a native button, not a MUI Button
|
|
111
|
-
|
|
117
|
+
useEnhancedEffect(() => {
|
|
112
118
|
if (autoFocus) {
|
|
113
119
|
// `ref.current` being `null` would be a bug in MUI.
|
|
114
|
-
ref.current
|
|
120
|
+
ref.current?.focus();
|
|
115
121
|
}
|
|
116
122
|
}, [autoFocus]);
|
|
123
|
+
const YearButton = slots?.yearButton ?? YearCalendarButton;
|
|
124
|
+
const yearButtonProps = useSlotProps({
|
|
125
|
+
elementType: YearButton,
|
|
126
|
+
externalSlotProps: slotProps?.yearButton,
|
|
127
|
+
additionalProps: {
|
|
128
|
+
children,
|
|
129
|
+
disabled,
|
|
130
|
+
tabIndex,
|
|
131
|
+
ref,
|
|
132
|
+
type: 'button',
|
|
133
|
+
role: 'radio',
|
|
134
|
+
'aria-current': ariaCurrent,
|
|
135
|
+
'aria-checked': selected,
|
|
136
|
+
onClick: event => onClick(event, value),
|
|
137
|
+
onKeyDown: event => onKeyDown(event, value),
|
|
138
|
+
onFocus: event => onFocus(event, value),
|
|
139
|
+
onBlur: event => onBlur(event, value)
|
|
140
|
+
},
|
|
141
|
+
ownerState: props,
|
|
142
|
+
className: classes.yearButton
|
|
143
|
+
});
|
|
117
144
|
return /*#__PURE__*/_jsx(PickersYearRoot, _extends({
|
|
118
145
|
className: clsx(classes.root, className),
|
|
119
146
|
ownerState: props
|
|
120
147
|
}, other, {
|
|
121
|
-
children: /*#__PURE__*/_jsx(
|
|
122
|
-
ref: ref,
|
|
123
|
-
disabled: disabled,
|
|
124
|
-
type: "button",
|
|
125
|
-
role: "radio",
|
|
126
|
-
tabIndex: disabled ? -1 : tabIndex,
|
|
127
|
-
"aria-current": ariaCurrent,
|
|
128
|
-
"aria-checked": selected,
|
|
129
|
-
onClick: event => onClick(event, value),
|
|
130
|
-
onKeyDown: event => onKeyDown(event, value),
|
|
131
|
-
onFocus: event => onFocus(event, value),
|
|
132
|
-
onBlur: event => onBlur(event, value),
|
|
133
|
-
className: classes.yearButton,
|
|
134
|
-
ownerState: props,
|
|
135
|
-
children: children
|
|
136
|
-
})
|
|
148
|
+
children: /*#__PURE__*/_jsx(YearButton, _extends({}, yearButtonProps))
|
|
137
149
|
}));
|
|
138
150
|
});
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
2
2
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
-
const _excluded = ["autoFocus", "className", "value", "defaultValue", "referenceDate", "disabled", "disableFuture", "disablePast", "maxDate", "minDate", "onChange", "readOnly", "shouldDisableYear", "disableHighlightToday", "onYearFocus", "hasFocus", "onFocusedViewChange", "yearsPerRow", "timezone", "gridLabelId"];
|
|
3
|
+
const _excluded = ["autoFocus", "className", "value", "defaultValue", "referenceDate", "disabled", "disableFuture", "disablePast", "maxDate", "minDate", "onChange", "readOnly", "shouldDisableYear", "disableHighlightToday", "onYearFocus", "hasFocus", "onFocusedViewChange", "yearsPerRow", "timezone", "gridLabelId", "slots", "slotProps"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import clsx from 'clsx';
|
|
7
|
-
import {
|
|
7
|
+
import { useRtl } from '@mui/system/RtlProvider';
|
|
8
8
|
import { styled, useThemeProps } from '@mui/material/styles';
|
|
9
9
|
import { unstable_useForkRef as useForkRef, unstable_composeClasses as composeClasses, unstable_useControlled as useControlled, unstable_useEventCallback as useEventCallback } from '@mui/utils';
|
|
10
10
|
import { PickersYear } from './PickersYear';
|
|
@@ -88,7 +88,9 @@ export const YearCalendar = /*#__PURE__*/React.forwardRef(function YearCalendar(
|
|
|
88
88
|
onFocusedViewChange,
|
|
89
89
|
yearsPerRow,
|
|
90
90
|
timezone: timezoneProp,
|
|
91
|
-
gridLabelId
|
|
91
|
+
gridLabelId,
|
|
92
|
+
slots,
|
|
93
|
+
slotProps
|
|
92
94
|
} = props,
|
|
93
95
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
94
96
|
const {
|
|
@@ -104,7 +106,7 @@ export const YearCalendar = /*#__PURE__*/React.forwardRef(function YearCalendar(
|
|
|
104
106
|
valueManager: singleItemValueManager
|
|
105
107
|
});
|
|
106
108
|
const now = useNow(timezone);
|
|
107
|
-
const
|
|
109
|
+
const isRtl = useRtl();
|
|
108
110
|
const utils = useUtils();
|
|
109
111
|
const referenceDate = React.useMemo(() => singleItemValueManager.getInitialReferenceValue({
|
|
110
112
|
value,
|
|
@@ -184,11 +186,11 @@ export const YearCalendar = /*#__PURE__*/React.forwardRef(function YearCalendar(
|
|
|
184
186
|
event.preventDefault();
|
|
185
187
|
break;
|
|
186
188
|
case 'ArrowLeft':
|
|
187
|
-
focusYear(year + (
|
|
189
|
+
focusYear(year + (isRtl ? 1 : -1));
|
|
188
190
|
event.preventDefault();
|
|
189
191
|
break;
|
|
190
192
|
case 'ArrowRight':
|
|
191
|
-
focusYear(year + (
|
|
193
|
+
focusYear(year + (isRtl ? -1 : 1));
|
|
192
194
|
event.preventDefault();
|
|
193
195
|
break;
|
|
194
196
|
default:
|
|
@@ -244,11 +246,13 @@ export const YearCalendar = /*#__PURE__*/React.forwardRef(function YearCalendar(
|
|
|
244
246
|
onKeyDown: handleKeyDown,
|
|
245
247
|
autoFocus: internalHasFocus && yearNumber === focusedYear,
|
|
246
248
|
disabled: isDisabled,
|
|
247
|
-
tabIndex: yearNumber === focusedYear ? 0 : -1,
|
|
249
|
+
tabIndex: yearNumber === focusedYear && !isDisabled ? 0 : -1,
|
|
248
250
|
onFocus: handleYearFocus,
|
|
249
251
|
onBlur: handleYearBlur,
|
|
250
252
|
"aria-current": todayYear === yearNumber ? 'date' : undefined,
|
|
251
253
|
yearsPerRow: yearsPerRow,
|
|
254
|
+
slots: slots,
|
|
255
|
+
slotProps: slotProps,
|
|
252
256
|
children: utils.format(year, 'year')
|
|
253
257
|
}, utils.format(year, 'year'));
|
|
254
258
|
})
|
|
@@ -323,6 +327,16 @@ process.env.NODE_ENV !== "production" ? YearCalendar.propTypes = {
|
|
|
323
327
|
* @returns {boolean} If `true`, the year will be disabled.
|
|
324
328
|
*/
|
|
325
329
|
shouldDisableYear: PropTypes.func,
|
|
330
|
+
/**
|
|
331
|
+
* The props used for each component slot.
|
|
332
|
+
* @default {}
|
|
333
|
+
*/
|
|
334
|
+
slotProps: PropTypes.object,
|
|
335
|
+
/**
|
|
336
|
+
* Overridable component slots.
|
|
337
|
+
* @default {}
|
|
338
|
+
*/
|
|
339
|
+
slots: PropTypes.object,
|
|
326
340
|
/**
|
|
327
341
|
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
328
342
|
*/
|
|
@@ -1,8 +1,23 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
1
2
|
import { SxProps } from '@mui/system';
|
|
2
3
|
import { Theme } from '@mui/material/styles';
|
|
3
4
|
import { YearCalendarClasses } from './yearCalendarClasses';
|
|
4
5
|
import { BaseDateValidationProps, YearValidationProps } from '../internals/models/validation';
|
|
5
6
|
import { PickerValidDate, TimezoneProps } from '../models';
|
|
7
|
+
import type { PickersYearProps } from './PickersYear';
|
|
8
|
+
import { SlotComponentPropsFromProps } from '../internals/models/helpers';
|
|
9
|
+
export interface YearCalendarSlots {
|
|
10
|
+
/**
|
|
11
|
+
* Button displayed to render a single year in the "year" view.
|
|
12
|
+
* @default YearCalendarButton
|
|
13
|
+
*/
|
|
14
|
+
yearButton?: React.ElementType;
|
|
15
|
+
}
|
|
16
|
+
export interface YearCalendarSlotProps {
|
|
17
|
+
yearButton?: SlotComponentPropsFromProps<React.HTMLAttributes<HTMLButtonElement> & {
|
|
18
|
+
sx: SxProps;
|
|
19
|
+
}, {}, PickersYearProps>;
|
|
20
|
+
}
|
|
6
21
|
export interface ExportedYearCalendarProps {
|
|
7
22
|
/**
|
|
8
23
|
* Years rendered per row.
|
|
@@ -17,6 +32,16 @@ export interface YearCalendarProps<TDate extends PickerValidDate> extends Export
|
|
|
17
32
|
* Override or extend the styles applied to the component.
|
|
18
33
|
*/
|
|
19
34
|
classes?: Partial<YearCalendarClasses>;
|
|
35
|
+
/**
|
|
36
|
+
* Overridable component slots.
|
|
37
|
+
* @default {}
|
|
38
|
+
*/
|
|
39
|
+
slots?: YearCalendarSlots;
|
|
40
|
+
/**
|
|
41
|
+
* The props used for each component slot.
|
|
42
|
+
* @default {}
|
|
43
|
+
*/
|
|
44
|
+
slotProps?: YearCalendarSlotProps;
|
|
20
45
|
/**
|
|
21
46
|
* The system prop that allows defining system overrides as well as additional CSS styles.
|
|
22
47
|
*/
|
package/YearCalendar/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { YearCalendar } from './YearCalendar';
|
|
2
|
-
export type { YearCalendarProps } from './YearCalendar.types';
|
|
2
|
+
export type { YearCalendarProps, YearCalendarSlots, YearCalendarSlotProps, } from './YearCalendar.types';
|
|
3
3
|
export { yearCalendarClasses, getYearCalendarUtilityClass } from './yearCalendarClasses';
|
|
4
4
|
export type { YearCalendarClasses, YearCalendarClassKey } from './yearCalendarClasses';
|
|
5
5
|
export { pickersYearClasses } from './pickersYearClasses';
|
package/index.js
CHANGED