@@ -14,6 +14,7 @@ type CalendarHeaderProps = {
14
14
isRange : boolean ;
15
15
date : DateValue | DatesRangeValue ;
16
16
pickerType : PickerType ;
17
+ showLevelChangeLink ?: boolean ;
17
18
onNextMonth : ( ) => void ;
18
19
onPreviousMonth : ( ) => void ;
19
20
onNextYear : ( ) => void ;
@@ -22,6 +23,35 @@ type CalendarHeaderProps = {
22
23
onPreviousDecade : ( ) => void ;
23
24
onLevelChange : ( level : MantineCalendarLevel ) => void ;
24
25
} ;
26
+ const CalendarLevelIndicator = ( {
27
+ onClick,
28
+ showLevelChangeLink,
29
+ accessibilityLabel,
30
+ text,
31
+ } : {
32
+ onClick : ( ) => void ;
33
+ showLevelChangeLink ?: boolean ;
34
+ accessibilityLabel : string ;
35
+ text : string ;
36
+ } ) : React . ReactElement => {
37
+ return showLevelChangeLink ? (
38
+ < Link
39
+ onClick = { onClick }
40
+ size = "large"
41
+ variant = "button"
42
+ color = "neutral"
43
+ iconPosition = "right"
44
+ icon = { ChevronDownIcon }
45
+ accessibilityLabel = { accessibilityLabel }
46
+ >
47
+ { text }
48
+ </ Link >
49
+ ) : (
50
+ < Text size = "large" weight = "medium" color = "interactive.text.neutral.normal" >
51
+ { text }
52
+ </ Text >
53
+ ) ;
54
+ } ;
25
55
26
56
const CalendarHeader = ( {
27
57
isRange,
@@ -34,7 +64,10 @@ const CalendarHeader = ({
34
64
onPreviousYear,
35
65
onPreviousDecade,
36
66
onLevelChange,
37
- } : CalendarHeaderProps ) : React . ReactElement => {
67
+ showLevelChangeLink,
68
+ } : CalendarHeaderProps & {
69
+ showLevelChangeLink ?: boolean ;
70
+ } ) : React . ReactElement => {
38
71
const { i18nState } = useI18nContext ( ) ;
39
72
const locale = convertIntlToDayjsLocale ( i18nState ?. locale ?? 'en-IN' ) ;
40
73
@@ -135,34 +168,21 @@ const CalendarHeader = ({
135
168
) : (
136
169
< Box display = "flex" gap = "spacing.5" alignItems = "center" >
137
170
{ pickerType === 'day' && (
138
- < Link
139
- onClick = { ( ) => {
140
- onLevelChange ( 'year' ) ;
141
- } }
142
- size = "large"
143
- variant = "button"
144
- color = "neutral"
145
- iconPosition = "right"
146
- icon = { ChevronDownIcon }
171
+ < CalendarLevelIndicator
172
+ onClick = { ( ) => onLevelChange ( 'month' ) }
173
+ showLevelChangeLink = { showLevelChangeLink }
147
174
accessibilityLabel = "Change month"
148
- >
149
- { month } { year }
150
- </ Link >
175
+ text = { `${ month } ${ year } ` }
176
+ />
151
177
) }
178
+
152
179
{ pickerType === 'month' && (
153
- < Link
154
- onClick = { ( ) => {
155
- onLevelChange ( 'decade' ) ;
156
- } }
157
- size = "large"
158
- variant = "button"
159
- color = "neutral"
160
- iconPosition = "right"
161
- icon = { ChevronDownIcon }
180
+ < CalendarLevelIndicator
181
+ onClick = { ( ) => onLevelChange ( 'decade' ) }
182
+ showLevelChangeLink = { showLevelChangeLink }
162
183
accessibilityLabel = "Change decade"
163
- >
164
- { year }
165
- </ Link >
184
+ text = { year }
185
+ />
166
186
) }
167
187
{ pickerType === 'year' && (
168
188
< Text size = "large" weight = "medium" color = "interactive.text.neutral.normal" >
0 commit comments