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