@@ -34,69 +34,71 @@ const DatePickerToolbarTitle = styled(
34
34
/**
35
35
* @ignore - internal component.
36
36
*/
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 ( ) ;
51
52
52
- const dateText = React . useMemo ( ( ) => {
53
- if ( ! date ) {
54
- return toolbarPlaceholder ;
55
- }
53
+ const dateText = React . useMemo ( ( ) => {
54
+ if ( ! date ) {
55
+ return toolbarPlaceholder ;
56
+ }
56
57
57
- if ( toolbarFormat ) {
58
- return utils . formatByString ( date , toolbarFormat ) ;
59
- }
58
+ if ( toolbarFormat ) {
59
+ return utils . formatByString ( date , toolbarFormat ) ;
60
+ }
60
61
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
+ }
64
65
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
+ }
68
69
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 / e n / . 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 / e n / . test ( utils . getCurrentLocaleCode ( ) )
74
+ ? utils . format ( date , 'normalDateWithWeekday' )
75
+ : utils . format ( date , 'normalDate' ) ;
76
+ } , [ date , toolbarFormat , toolbarPlaceholder , utils , views ] ) ;
76
77
77
- const styleProps = { ...props } ;
78
+ const styleProps = { ...props } ;
78
79
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 }
94
88
styleProps = { styleProps }
89
+ { ...other }
95
90
>
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
+ ) ;
101
103
102
104
export default DatePickerToolbar ;
0 commit comments