@@ -43,6 +43,8 @@ import {
43
43
jsonValueExposingStateControl ,
44
44
CalendarDeleteIcon ,
45
45
Tooltip ,
46
+ AbstractComp ,
47
+ MultiBaseComp ,
46
48
} from "lowcoder-sdk" ;
47
49
48
50
import {
@@ -71,6 +73,7 @@ import {
71
73
72
74
// this should ensure backwards compatibility with older versions of the SDK
73
75
const safeDragEventHandlerControl = typeof DragEventHandlerControl !== 'undefined' ? DragEventHandlerControl : ( ) => { } ;
76
+ const isVariantCompAvailable = typeof AbstractComp !== 'undefined' && AbstractComp !== null && typeof MultiBaseComp !== 'undefined' && MultiBaseComp !== null ;
74
77
75
78
const childrenMap = {
76
79
events : jsonValueExposingStateControl ( "events" , defaultData ) ,
@@ -624,17 +627,25 @@ const TmpCalendarComp = withExposingConfigs(CalendarBasicComp, [
624
627
NameConfigHidden ,
625
628
] ) ;
626
629
627
- export const CalendarComp = withMethodExposing ( TmpCalendarComp , [
628
- {
629
- method : {
630
- name : "setCalendarView" ,
631
- description : "timeGridWeek || timeGridDay || dayGridMonth || listWeek || resourceTimelineDay || resourceTimeGridDay || resourceTimelineWeek || resourceTimelineMonth" ,
632
- params : [ { name : "viewType" , type : "string" } ] ,
633
- } ,
634
- execute : ( comp , values ) => {
635
- const viewType = values [ 0 ] as string ;
636
- viewType == "" ? viewType : "timeGridWeek" ;
637
- return comp . children . licenseKey . getView ( ) == "" ? comp . children . defaultFreeView . dispatchChangeValueAction ( viewType ) : comp . children . defaultPremiumView . dispatchChangeValueAction ( viewType ) ;
638
- }
639
- } ,
640
- ] ) ;
630
+ let CalendarComp ;
631
+
632
+ if ( isVariantCompAvailable ) {
633
+ CalendarComp = withMethodExposing ( TmpCalendarComp , [
634
+ {
635
+ method : {
636
+ name : "setCalendarView" ,
637
+ description : "Sets the view of the calendar to a specified type" ,
638
+ params : [ { name : "viewType" , type : "string" } ] ,
639
+ } ,
640
+ execute : ( comp , values ) => {
641
+ const viewType = values [ 0 ] as string || "timeGridWeek" ; // Default to "timeGridWeek" if undefined
642
+ const viewKey = comp . children . licenseKey . getView ( ) === "" ? 'defaultFreeView' : 'defaultPremiumView' ;
643
+ comp . children [ viewKey ] . dispatchChangeValueAction ( viewType ) ;
644
+ }
645
+ } ,
646
+ ] ) ;
647
+ } else {
648
+ CalendarComp = TmpCalendarComp ;
649
+ }
650
+
651
+ export { CalendarComp } ;
0 commit comments