@@ -43,6 +43,8 @@ import {
4343 jsonValueExposingStateControl ,
4444 CalendarDeleteIcon ,
4545 Tooltip ,
46+ AbstractComp ,
47+ MultiBaseComp ,
4648} from "lowcoder-sdk" ;
4749
4850import {
@@ -71,6 +73,7 @@ import {
7173
7274// this should ensure backwards compatibility with older versions of the SDK
7375const safeDragEventHandlerControl = typeof DragEventHandlerControl !== 'undefined' ? DragEventHandlerControl : ( ) => { } ;
76+ const isVariantCompAvailable = typeof AbstractComp !== 'undefined' && AbstractComp !== null && typeof MultiBaseComp !== 'undefined' && MultiBaseComp !== null ;
7477
7578const childrenMap = {
7679 events : jsonValueExposingStateControl ( "events" , defaultData ) ,
@@ -624,17 +627,25 @@ const TmpCalendarComp = withExposingConfigs(CalendarBasicComp, [
624627 NameConfigHidden ,
625628] ) ;
626629
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