@ -14,7 +14,7 @@ import { useLocaleUtils, useLocaleLanguage } from './shared/hooks';
import { Header , MonthSelector , YearSelector , DaysList } from './components' ;
export const Calendar = ( {
const Calendar = ( {
value ,
onChange ,
onDisabledDayError ,
@ -37,6 +37,7 @@ export const Calendar = ({
renderFooter ,
customDaysClassName ,
events ,
renderEvents ,
} ) => {
const calendarElement = useRef ( null ) ;
const [ mainState , setMainState ] = useState ( {
@ -45,7 +46,7 @@ export const Calendar = ({
isMonthSelectorOpen : false ,
isYearSelectorOpen : false ,
} ) ;
const [ eventInFooter , setEventInFooter ] = useState ( null ) ;
useEffect ( ( ) => {
const handleKeyUp = ( { key } ) => {
/* istanbul ignore else */
@ -188,11 +189,16 @@ export const Calendar = ({
shouldHighlightWeekends = { shouldHighlightWeekends }
customDaysClassName = { customDaysClassName }
events = { events }
renderFooter = { renderFooter }
renderEvents = { renderEvents }
isQuickSelectorOpen = {
mainState . isYearSelectorOpen || mainState . isMonthSelectorOpen
}
showEvent = { event => setEventInFooter ( event ) }
/ >
< div className = "Calendar__footer" > { renderFooter ( ) } < / d i v >
< div className = "Calendar__footer" >
< p className = 'footer__Events' > { eventInFooter } < / p >
{ renderFooter ( ) } < / d i v >
< / d i v >
) ;
} ;
@ -207,36 +213,64 @@ Calendar.defaultProps = {
locale : 'en' ,
value : null ,
renderFooter : ( ) => null ,
renderEvents : ( ) => null ,
customDaysClassName : [ ] ,
events : [
{
id : 1 ,
day : 15 ,
occasions : [
{
title : 'دی به دین روز، چهارمین جشن دیگان' ,
dotColor : '#eeffds1' ,
} ,
{
title : 'lorem' ,
dotColor : 'blue'
}
]
} ,
{
id : 2 ,
day : 22 ,
title : 'مصاحبه کاری' ,
dotColor : 'red' ,
} ,
{
id : 3 ,
title : 'اجاره خانه' ,
day : 21 ,
dotColor : 'blue' ,
} ,
description : "تست 2" ,
type : "global" ,
isHoliday : false ,
date : "2022-01-04T00:00:00.000Z" ,
year : 2022 ,
month : 1 ,
day : 2
} ,
{
id : 4 ,
description : "تست 4" ,
type : "global" ,
isHoliday : true ,
date : "2022-01-12T00:00:00.000Z" ,
year : 2022 ,
month : 1 ,
day : 3
} ,
{
id : 1 ,
description : "تست کاربر 1" ,
type : "userDefined" ,
userId : "5" ,
date : "2022-01-12T00:00:00.000Z" ,
categoryId : 1 ,
year : 2022 ,
month : 1 ,
day : 3
} ,
{
id : 4 ,
description : "تست کاربر 4" ,
type : "userDefined" ,
userId : "5" ,
date : "2022-01-08T00:00:00.000Z" ,
categoryId : 3 ,
year : 2022 ,
month : 1 ,
day : 6
} ,
{
id : 5 ,
description : "تست کاربر 5" ,
type : "userDefined" ,
userId : "5" ,
date : "2022-01-12T00:00:00.000Z" ,
categoryId : 1 ,
year : 2022 ,
month : 1 ,
day : 3
}
] ,
} ;
export default Calendar ;