@@ -32,6 +32,50 @@ export const Calendar: React.FC<CalendarProps> = ({
3232 fontFamily,
3333 fontSize,
3434} ) => {
35+ const getCalendarValuesForYear = ( ) => {
36+ const topValues : ReactChild [ ] = [ ] ;
37+ const bottomValues : ReactChild [ ] = [ ] ;
38+ const topDefaultHeight = headerHeight * 0.5 ;
39+ for ( let i = 0 ; i < dateSetup . dates . length ; i ++ ) {
40+ const date = dateSetup . dates [ i ] ;
41+ const bottomValue = date . getFullYear ( ) ;
42+ bottomValues . push (
43+ < text
44+ key = { date . getFullYear ( ) }
45+ y = { headerHeight * 0.8 }
46+ x = { columnWidth * i + columnWidth * 0.5 }
47+ className = { styles . calendarBottomText }
48+ >
49+ { bottomValue }
50+ </ text >
51+ ) ;
52+ if (
53+ i === 0 ||
54+ date . getFullYear ( ) !== dateSetup . dates [ i - 1 ] . getFullYear ( )
55+ ) {
56+ const topValue = date . getFullYear ( ) . toString ( ) ;
57+ let xText : number ;
58+ if ( rtl ) {
59+ xText = ( 6 + i + date . getFullYear ( ) + 1 ) * columnWidth ;
60+ } else {
61+ xText = ( 6 + i - date . getFullYear ( ) ) * columnWidth ;
62+ }
63+ topValues . push (
64+ < TopPartOfCalendar
65+ key = { topValue }
66+ value = { topValue }
67+ x1Line = { columnWidth * i }
68+ y1Line = { 0 }
69+ y2Line = { headerHeight }
70+ xText = { xText }
71+ yText = { topDefaultHeight * 0.9 }
72+ />
73+ ) ;
74+ }
75+ }
76+ return [ topValues , bottomValues ] ;
77+ } ;
78+
3579 const getCalendarValuesForMonth = ( ) => {
3680 const topValues : ReactChild [ ] = [ ] ;
3781 const bottomValues : ReactChild [ ] = [ ] ;
@@ -268,10 +312,13 @@ export const Calendar: React.FC<CalendarProps> = ({
268312 let topValues : ReactChild [ ] = [ ] ;
269313 let bottomValues : ReactChild [ ] = [ ] ;
270314 switch ( dateSetup . viewMode ) {
271- case ViewMode . Month :
272- [ topValues , bottomValues ] = getCalendarValuesForMonth ( ) ;
315+ case ViewMode . Year :
316+ [ topValues , bottomValues ] = getCalendarValuesForYear ( ) ;
273317 break ;
274- case ViewMode . Week :
318+ case ViewMode . Month :
319+ [ topValues , bottomValues ] = getCalendarValuesForMonth ( ) ;
320+ break ;
321+ case ViewMode . Week :
275322 [ topValues , bottomValues ] = getCalendarValuesForWeek ( ) ;
276323 break ;
277324 case ViewMode . Day :
0 commit comments