Skip to content

Commit 98705ba

Browse files
committed
prettier
1 parent a405d09 commit 98705ba

File tree

1 file changed

+57
-55
lines changed

1 file changed

+57
-55
lines changed

packages/material-ui-lab/src/DatePicker/DatePickerToolbar.tsx

+57-55
Original file line numberDiff line numberDiff line change
@@ -34,69 +34,71 @@ const DatePickerToolbarTitle = styled(
3434
/**
3535
* @ignore - internal component.
3636
*/
37-
const DatePickerToolbar = React.forwardRef<HTMLDivElement, ToolbarComponentProps>(function DatePickerToolbar(props, ref) {
38-
const {
39-
date,
40-
isLandscape,
41-
isMobileKeyboardViewOpen,
42-
onChange,
43-
toggleMobileKeyboardView,
44-
toolbarFormat,
45-
toolbarPlaceholder = '––',
46-
toolbarTitle = 'SELECT DATE',
47-
views,
48-
...other
49-
} = props;
50-
const utils = useUtils();
37+
const DatePickerToolbar = React.forwardRef<HTMLDivElement, ToolbarComponentProps>(
38+
function DatePickerToolbar(props, ref) {
39+
const {
40+
date,
41+
isLandscape,
42+
isMobileKeyboardViewOpen,
43+
onChange,
44+
toggleMobileKeyboardView,
45+
toolbarFormat,
46+
toolbarPlaceholder = '––',
47+
toolbarTitle = 'SELECT DATE',
48+
views,
49+
...other
50+
} = props;
51+
const utils = useUtils();
5152

52-
const dateText = React.useMemo(() => {
53-
if (!date) {
54-
return toolbarPlaceholder;
55-
}
53+
const dateText = React.useMemo(() => {
54+
if (!date) {
55+
return toolbarPlaceholder;
56+
}
5657

57-
if (toolbarFormat) {
58-
return utils.formatByString(date, toolbarFormat);
59-
}
58+
if (toolbarFormat) {
59+
return utils.formatByString(date, toolbarFormat);
60+
}
6061

61-
if (isYearOnlyView(views as CalendarPickerView[])) {
62-
return utils.format(date, 'year');
63-
}
62+
if (isYearOnlyView(views as CalendarPickerView[])) {
63+
return utils.format(date, 'year');
64+
}
6465

65-
if (isYearAndMonthViews(views as CalendarPickerView[])) {
66-
return utils.format(date, 'month');
67-
}
66+
if (isYearAndMonthViews(views as CalendarPickerView[])) {
67+
return utils.format(date, 'month');
68+
}
6869

69-
// Little localization hack (Google is doing the same for android native pickers):
70-
// For english localization it is convenient to include weekday into the date "Mon, Jun 1".
71-
// For other locales using strings like "June 1", without weekday.
72-
return /en/.test(utils.getCurrentLocaleCode())
73-
? utils.format(date, 'normalDateWithWeekday')
74-
: utils.format(date, 'normalDate');
75-
}, [date, toolbarFormat, toolbarPlaceholder, utils, views]);
70+
// Little localization hack (Google is doing the same for android native pickers):
71+
// For english localization it is convenient to include weekday into the date "Mon, Jun 1".
72+
// For other locales using strings like "June 1", without weekday.
73+
return /en/.test(utils.getCurrentLocaleCode())
74+
? utils.format(date, 'normalDateWithWeekday')
75+
: utils.format(date, 'normalDate');
76+
}, [date, toolbarFormat, toolbarPlaceholder, utils, views]);
7677

77-
const styleProps = { ...props };
78+
const styleProps = { ...props };
7879

79-
return (
80-
<DatePickerToolbarRoot
81-
ref={ref}
82-
toolbarTitle={toolbarTitle}
83-
isMobileKeyboardViewOpen={isMobileKeyboardViewOpen}
84-
toggleMobileKeyboardView={toggleMobileKeyboardView}
85-
isLandscape={isLandscape}
86-
penIconClassName={classes.penIcon}
87-
styleProps={styleProps}
88-
{...other}
89-
>
90-
<DatePickerToolbarTitle
91-
variant="h4"
92-
data-mui-test="datepicker-toolbar-date"
93-
align={isLandscape ? 'left' : 'center'}
80+
return (
81+
<DatePickerToolbarRoot
82+
ref={ref}
83+
toolbarTitle={toolbarTitle}
84+
isMobileKeyboardViewOpen={isMobileKeyboardViewOpen}
85+
toggleMobileKeyboardView={toggleMobileKeyboardView}
86+
isLandscape={isLandscape}
87+
penIconClassName={classes.penIcon}
9488
styleProps={styleProps}
89+
{...other}
9590
>
96-
{dateText}
97-
</DatePickerToolbarTitle>
98-
</DatePickerToolbarRoot>
99-
);
100-
});
91+
<DatePickerToolbarTitle
92+
variant="h4"
93+
data-mui-test="datepicker-toolbar-date"
94+
align={isLandscape ? 'left' : 'center'}
95+
styleProps={styleProps}
96+
>
97+
{dateText}
98+
</DatePickerToolbarTitle>
99+
</DatePickerToolbarRoot>
100+
);
101+
},
102+
);
101103

102104
export default DatePickerToolbar;

0 commit comments

Comments
 (0)