@@ -26,6 +26,7 @@ import { default as Form } from "antd/es/form";
2626import { default as Input } from "antd/es/input" ;
2727import { trans , getCalendarLocale } from "../../i18n/comps" ;
2828import { createRef , useContext , useRef , useState } from "react" ;
29+ import resourceTimelinePlugin from "@fullcalendar/resource-timeline" ;
2930import FullCalendar from "@fullcalendar/react" ;
3031import dayGridPlugin from "@fullcalendar/daygrid" ;
3132import timeGridPlugin from "@fullcalendar/timegrid" ;
@@ -66,8 +67,9 @@ const childrenMap = {
6667 dayMaxEvents : withDefault ( NumberControl , 2 ) ,
6768 eventMaxStack : withDefault ( NumberControl , 0 ) ,
6869 style : styleControl ( CalendarStyle ) ,
70+ licenceKey : withDefault ( StringControl , "" ) ,
6971} ;
70-
72+
7173let CalendarBasicComp = ( function ( ) {
7274 return new UICompBuilder ( childrenMap , ( props ) => {
7375 const theme = useContext ( ThemeContext ) ;
@@ -83,7 +85,9 @@ let CalendarBasicComp = (function () {
8385 start : dayjs ( item . start , DateParser ) . format ( ) ,
8486 end : dayjs ( item . end , DateParser ) . format ( ) ,
8587 allDay : item . allDay ,
86- color : isValidColor ( item . color || "" ) ? item . color : theme ?. theme ?. primary ,
88+ color : isValidColor ( item . color || "" )
89+ ? item . color
90+ : theme ?. theme ?. primary ,
8791 ...( item . groupId ? { groupId : item . groupId } : null ) ,
8892 } ;
8993 } ) ;
@@ -104,8 +108,13 @@ let CalendarBasicComp = (function () {
104108 function renderEventContent ( eventInfo : EventContentArg ) {
105109 const isList = eventInfo . view . type === "listWeek" ;
106110 let sizeClass = "" ;
107- if ( [ ViewType . WEEK , ViewType . DAY ] . includes ( eventInfo . view . type as ViewType ) ) {
108- const duration = dayjs ( eventInfo . event . end ) . diff ( dayjs ( eventInfo . event . start ) , "minutes" ) ;
111+ if (
112+ [ ViewType . WEEK , ViewType . DAY ] . includes ( eventInfo . view . type as ViewType )
113+ ) {
114+ const duration = dayjs ( eventInfo . event . end ) . diff (
115+ dayjs ( eventInfo . event . start ) ,
116+ "minutes"
117+ ) ;
109118 if ( duration <= 30 || eventInfo . event . allDay ) {
110119 sizeClass = "small" ;
111120 } else if ( duration <= 60 ) {
@@ -137,7 +146,9 @@ let CalendarBasicComp = (function () {
137146 onClick = { ( e ) => {
138147 e . stopPropagation ( ) ;
139148 props . onEvent ( "change" ) ;
140- const event = events . filter ( ( item : EventType ) => item . id !== eventInfo . event . id ) ;
149+ const event = events . filter (
150+ ( item : EventType ) => item . id !== eventInfo . event . id
151+ ) ;
141152 props . events . onChange ( event ) ;
142153 } }
143154 onMouseDown = { ( e ) => {
@@ -195,7 +206,9 @@ let CalendarBasicComp = (function () {
195206 } ;
196207
197208 const showModal = ( event : EventType , ifEdit : boolean ) => {
198- const modalTitle = ifEdit ? trans ( "calendar.editEvent" ) : trans ( "calendar.creatEvent" ) ;
209+ const modalTitle = ifEdit
210+ ? trans ( "calendar.editEvent" )
211+ : trans ( "calendar.creatEvent" ) ;
199212 form && form . setFieldsValue ( event ) ;
200213 const eventId = editEvent . current ?. id ;
201214 CustomModal . confirm ( {
@@ -209,14 +222,18 @@ let CalendarBasicComp = (function () {
209222 </ Tooltip >
210223 }
211224 name = "id"
212- rules = { [ { required : true , message : trans ( "calendar.eventIdRequire" ) } ] }
225+ rules = { [
226+ { required : true , message : trans ( "calendar.eventIdRequire" ) } ,
227+ ] }
213228 >
214229 < Input />
215230 </ Form . Item >
216231 < Form . Item
217232 label = { trans ( "calendar.eventName" ) }
218233 name = "title"
219- rules = { [ { required : true , message : trans ( "calendar.eventNameRequire" ) } ] }
234+ rules = { [
235+ { required : true , message : trans ( "calendar.eventNameRequire" ) } ,
236+ ] }
220237 >
221238 < Input />
222239 </ Form . Item >
@@ -239,9 +256,13 @@ let CalendarBasicComp = (function () {
239256 form . submit ( ) ;
240257 return form . validateFields ( ) . then ( ( ) => {
241258 const { id, groupId, color, title = "" } = form . getFieldsValue ( ) ;
242- const idExist = props . events . value . findIndex ( ( item : EventType ) => item . id === id ) ;
259+ const idExist = props . events . value . findIndex (
260+ ( item : EventType ) => item . id === id
261+ ) ;
243262 if ( idExist > - 1 && id !== eventId ) {
244- form . setFields ( [ { name : "id" , errors : [ trans ( "calendar.eventIdExist" ) ] } ] ) ;
263+ form . setFields ( [
264+ { name : "id" , errors : [ trans ( "calendar.eventIdExist" ) ] } ,
265+ ] ) ;
245266 throw new Error ( ) ;
246267 }
247268 if ( ifEdit ) {
@@ -306,7 +327,14 @@ let CalendarBasicComp = (function () {
306327 locale = { getCalendarLocale ( ) }
307328 locales = { allLocales }
308329 firstDay = { Number ( firstDay ) }
309- plugins = { [ dayGridPlugin , timeGridPlugin , interactionPlugin , listPlugin , momentPlugin ] }
330+ plugins = { [
331+ dayGridPlugin ,
332+ timeGridPlugin ,
333+ interactionPlugin ,
334+ listPlugin ,
335+ momentPlugin ,
336+ resourceTimelinePlugin ,
337+ ] }
310338 headerToolbar = { headerToolbar }
311339 moreLinkClick = { ( info ) => {
312340 let left = 0 ;
@@ -319,15 +347,19 @@ let CalendarBasicComp = (function () {
319347 }
320348 } else {
321349 if ( info . allDay ) {
322- left = ele . offsetParent ?. parentElement ?. parentElement ?. offsetLeft || 0 ;
350+ left =
351+ ele . offsetParent ?. parentElement ?. parentElement ?. offsetLeft ||
352+ 0 ;
323353 } else {
324354 left =
325- ele . offsetParent ?. parentElement ?. parentElement ?. parentElement ?. offsetLeft || 0 ;
355+ ele . offsetParent ?. parentElement ?. parentElement ?. parentElement
356+ ?. offsetLeft || 0 ;
326357 }
327358 }
328359 setLeft ( left ) ;
329360 } }
330361 buttonText = { buttonText }
362+ schedulerLicenseKey = { props . licenceKey . value }
331363 views = { views }
332364 eventClassNames = { ( ) => ( ! showEventTime ? "no-time" : "" ) }
333365 slotLabelFormat = { slotLabelFormat }
@@ -346,7 +378,9 @@ let CalendarBasicComp = (function () {
346378 eventContent = { renderEventContent }
347379 select = { ( info ) => handleCreate ( info ) }
348380 eventClick = { ( info ) => {
349- const event = events . find ( ( item : EventType ) => item . id === info . event . id ) ;
381+ const event = events . find (
382+ ( item : EventType ) => item . id === info . event . id
383+ ) ;
350384 editEvent . current = event ;
351385 setTimeout ( ( ) => {
352386 editEvent . current = undefined ;
@@ -387,12 +421,19 @@ let CalendarBasicComp = (function () {
387421 . setPropertyViewFn ( ( children ) => {
388422 return (
389423 < >
390- < Section name = { sectionNames . basic } > { children . events . propertyView ( { } ) } </ Section >
391- < Section name = { sectionNames . interaction } > { children . onEvent . getPropertyView ( ) } </ Section >
424+ < Section name = { sectionNames . basic } >
425+ { children . events . propertyView ( { } ) }
426+ </ Section >
427+ < Section name = { sectionNames . interaction } >
428+ { children . licenceKey . propertyView ( {
429+ label : trans ( "calendar.licence" ) ,
430+ } ) }
431+ { children . onEvent . getPropertyView ( ) }
432+ </ Section >
392433 < Section name = { sectionNames . advanced } >
393434 { children . editable . propertyView ( {
394- label : trans ( "calendar.editable" ) ,
395- } ) }
435+ label : trans ( "calendar.editable" ) ,
436+ } ) }
396437 { children . defaultDate . propertyView ( {
397438 label : trans ( "calendar.defaultDate" ) ,
398439 tooltip : trans ( "calendar.defaultDateTooltip" ) ,
@@ -424,8 +465,12 @@ let CalendarBasicComp = (function () {
424465 tooltip : trans ( "calendar.eventMaxStackTooltip" ) ,
425466 } ) }
426467 </ Section >
427- < Section name = { sectionNames . layout } > { hiddenPropertyView ( children ) } </ Section >
428- < Section name = { sectionNames . style } > { children . style . getPropertyView ( ) } </ Section >
468+ < Section name = { sectionNames . layout } >
469+ { hiddenPropertyView ( children ) }
470+ </ Section >
471+ < Section name = { sectionNames . style } >
472+ { children . style . getPropertyView ( ) }
473+ </ Section >
429474 </ >
430475 ) ;
431476 } )
0 commit comments