@@ -15,7 +15,10 @@ import {
1515 lightenColor ,
1616 toHex ,
1717 UnderlineCss ,
18- EventModalStyleType
18+ EventModalStyleType ,
19+ DateParser ,
20+ isValidColor ,
21+ Theme ,
1922} from "lowcoder-sdk" ;
2023import styled from "styled-components" ;
2124import dayjs from "dayjs" ;
@@ -27,6 +30,10 @@ import {
2730} from "@fullcalendar/core" ;
2831import { default as Form } from "antd/es/form" ;
2932
33+ type Theme = typeof Theme ;
34+ type EventModalStyleType = typeof EventModalStyleType ;
35+ type CalendarStyleType = typeof CalendarStyleType ;
36+
3037export const Wrapper = styled . div < {
3138 $editable ?: boolean ;
3239 $style ?: CalendarStyleType ;
@@ -1135,3 +1142,32 @@ export const viewClassNames = (info: ViewContentArg) => {
11351142 return className ;
11361143} ;
11371144
1145+ export const formattedEvents = ( events : EventType [ ] , theme ?: Theme ) => {
1146+ return events . map ( ( item : EventType ) => {
1147+ return {
1148+ title : item . label ,
1149+ label : item . label ,
1150+ id : item . id ,
1151+ start : dayjs ( item . start , DateParser ) . format ( ) ,
1152+ end : dayjs ( item . end , DateParser ) . format ( ) ,
1153+ allDay : item . allDay ,
1154+ ...( item . resourceId ? { resourceId : item . resourceId } : { } ) ,
1155+ ...( item . groupId ? { groupId : item . groupId } : { } ) ,
1156+ backgroundColor : item . backgroundColor ,
1157+ extendedProps : { // Ensure color is in extendedProps
1158+ color : isValidColor ( item . color || "" ) ? item . color : theme ?. theme ?. primary ,
1159+ detail : item . detail ,
1160+ titleColor : item . titleColor ,
1161+ detailColor : item . detailColor ,
1162+ titleFontWeight : item . titleFontWeight ,
1163+ titleFontStyle : item . titleFontStyle ,
1164+ detailFontWeight : item . detailFontWeight ,
1165+ detailFontStyle : item . detailFontStyle ,
1166+ animation : item ?. animation ,
1167+ animationDelay : item ?. animationDelay ,
1168+ animationDuration : item ?. animationDuration ,
1169+ animationIterationCount : item ?. animationIterationCount
1170+ }
1171+ }
1172+ } )
1173+ }
0 commit comments