@@ -114,6 +114,14 @@ export interface ReactDatePickerCustomHeaderProps {
114114 } ;
115115}
116116
117+ export interface ReactDatePickerCustomDayNameProps {
118+ day : Date ;
119+ shortName : string ;
120+ fullName : string ;
121+ locale ?: Locale ;
122+ customDayNameCount : number ;
123+ }
124+
117125type CalendarProps = React . PropsWithChildren <
118126 Omit <
119127 YearDropdownProps ,
@@ -195,6 +203,9 @@ type CalendarProps = React.PropsWithChildren<
195203 renderCustomHeader ?: (
196204 props : ReactDatePickerCustomHeaderProps ,
197205 ) => React . ReactElement ;
206+ renderCustomDayName ?: (
207+ props : ReactDatePickerCustomDayNameProps ,
208+ ) => React . ReactNode ;
198209 onYearMouseEnter ?: YearProps [ "onYearMouseEnter" ] ;
199210 onYearMouseLeave ?: YearProps [ "onYearMouseLeave" ] ;
200211 monthAriaLabelPrefix ?: MonthProps [ "ariaLabelPrefix" ] ;
@@ -477,7 +488,10 @@ export default class Calendar extends Component<CalendarProps, CalendarState> {
477488 ) ;
478489 } ;
479490
480- header = ( date : Date = this . state . date ) : React . ReactElement [ ] => {
491+ header = (
492+ date : Date = this . state . date ,
493+ customDayNameCount : number = 0 ,
494+ ) : React . ReactElement [ ] => {
481495 // Return empty array if date is invalid
482496 if ( ! isValid ( date ) ) {
483497 return [ ] ;
@@ -507,11 +521,38 @@ export default class Calendar extends Component<CalendarProps, CalendarState> {
507521 [ 0 , 1 , 2 , 3 , 4 , 5 , 6 ] . map ( ( offset ) => {
508522 const day = addDays ( startOfWeek , offset ) ;
509523 const weekDayName = this . formatWeekday ( day , this . props . locale ) ;
524+ const fullDayName = formatDate ( day , "EEEE" , this . props . locale ) ;
510525
511526 const weekDayClassName = this . props . weekDayClassName
512527 ? this . props . weekDayClassName ( day )
513528 : undefined ;
514529
530+ // Use custom render if provided
531+ if ( this . props . renderCustomDayName ) {
532+ const customContent = this . props . renderCustomDayName ( {
533+ day,
534+ shortName : weekDayName ,
535+ fullName : fullDayName ,
536+ locale : this . props . locale ,
537+ customDayNameCount,
538+ } ) ;
539+
540+ return (
541+ < div
542+ key = { offset }
543+ role = "columnheader"
544+ className = { clsx (
545+ "react-datepicker__day-name" ,
546+ weekDayClassName ,
547+ disabled ? "react-datepicker__day-name--disabled" : "" ,
548+ ) }
549+ >
550+ { customContent }
551+ </ div >
552+ ) ;
553+ }
554+
555+ // Default render
515556 return (
516557 < div
517558 key = { offset }
@@ -522,9 +563,7 @@ export default class Calendar extends Component<CalendarProps, CalendarState> {
522563 disabled ? "react-datepicker__day-name--disabled" : "" ,
523564 ) }
524565 >
525- < span className = "react-datepicker__sr-only" >
526- { formatDate ( day , "EEEE" , this . props . locale ) }
527- </ span >
566+ < span className = "react-datepicker__sr-only" > { fullDayName } </ span >
528567 < span aria-hidden = "true" > { weekDayName } </ span >
529568 </ div >
530569 ) ;
@@ -871,9 +910,9 @@ export default class Calendar extends Component<CalendarProps, CalendarState> {
871910 ) ;
872911 } ;
873912
874- renderDayNamesHeader = ( monthDate : Date ) => (
913+ renderDayNamesHeader = ( monthDate : Date , customDayNameCount : number = 0 ) => (
875914 < div className = "react-datepicker__day-names" role = "row" >
876- { this . header ( monthDate ) }
915+ { this . header ( monthDate , customDayNameCount ) }
877916 </ div >
878917 ) ;
879918
@@ -1055,7 +1094,7 @@ export default class Calendar extends Component<CalendarProps, CalendarState> {
10551094 selectingDate = { this . state . selectingDate }
10561095 monthShowsDuplicateDaysEnd = { monthShowsDuplicateDaysEnd }
10571096 monthShowsDuplicateDaysStart = { monthShowsDuplicateDaysStart }
1058- dayNamesHeader = { this . renderDayNamesHeader ( monthDate ) }
1097+ dayNamesHeader = { this . renderDayNamesHeader ( monthDate , i ) }
10591098 />
10601099 </ div > ,
10611100 ) ;
0 commit comments