lowcoder-comps 0.0.29 → 0.0.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +120 -0
- package/index.html +26 -0
- package/index.tsx +21 -0
- package/jest.config.js +6 -0
- package/package.json +3 -4
- package/src/__test__/allComp.test.tsx +61 -0
- package/src/app-env.d.ts +3 -0
- package/src/comps/calendarComp/calendarComp.tsx +633 -0
- package/src/comps/calendarComp/calendarConstants.tsx +1048 -0
- package/src/comps/calendarComp/errorBoundary.tsx +30 -0
- package/src/comps/chartComp/chartComp.tsx +442 -0
- package/src/comps/chartComp/chartConfigs/barChartConfig.tsx +51 -0
- package/src/comps/chartComp/chartConfigs/cartesianAxisConfig.tsx +307 -0
- package/src/comps/chartComp/chartConfigs/chartUrls.tsx +9 -0
- package/src/comps/chartComp/chartConfigs/legendConfig.tsx +55 -0
- package/src/comps/chartComp/chartConfigs/lineChartConfig.tsx +96 -0
- package/src/comps/chartComp/chartConfigs/pieChartConfig.tsx +83 -0
- package/src/comps/chartComp/chartConfigs/scatterChartConfig.tsx +62 -0
- package/src/comps/chartComp/chartConstants.tsx +299 -0
- package/src/comps/chartComp/chartPropertyView.tsx +235 -0
- package/src/comps/chartComp/chartUtils.ts +291 -0
- package/src/comps/chartComp/reactEcharts/core.tsx +194 -0
- package/src/comps/chartComp/reactEcharts/index.ts +21 -0
- package/src/comps/chartComp/reactEcharts/types.ts +76 -0
- package/src/comps/chartComp/seriesComp.tsx +119 -0
- package/src/comps/imageEditorComp/imageEditorClass.tsx +52 -0
- package/src/comps/imageEditorComp/imageEditorConstants.tsx +109 -0
- package/src/comps/imageEditorComp/index.tsx +184 -0
- package/src/comps/mermaidComp/index.tsx +44 -0
- package/src/comps/mermaidComp/mermaid.tsx +29 -0
- package/src/global.ts +1 -0
- package/src/i18n/comps/index.tsx +29 -0
- package/src/i18n/comps/locales/en.ts +163 -0
- package/src/i18n/comps/locales/enObj.tsx +198 -0
- package/src/i18n/comps/locales/index.ts +7 -0
- package/src/i18n/comps/locales/types.tsx +10 -0
- package/src/i18n/comps/locales/zh.ts +156 -0
- package/src/i18n/comps/locales/zhObj.tsx +4 -0
- package/src/index.ts +11 -0
- package/tsconfig.json +22 -0
- package/vite.config.js +10 -0
- package/2085da13.js +0 -960
- package/250691b5.js +0 -5
- package/256b619e.js +0 -92
- package/274f545c.js +0 -881
- package/289305a1.js +0 -208
- package/2eae45c2.js +0 -34
- package/2ff2c7a6.js +0 -6
- package/2ff7471d.js +0 -9
- package/335b22a2.js +0 -220
- package/38c826fe.js +0 -1127
- package/44011c1d.js +0 -818
- package/4fc06812.js +0 -64
- package/56a787cf.js +0 -915
- package/590941ff.js +0 -86
- package/6341867f.js +0 -804
- package/657fd065.js +0 -8
- package/78a5e50d.js +0 -1579
- package/820c3641.js +0 -25
- package/88b4e75a.js +0 -2967
- package/8d999722.js +0 -1102
- package/92e85b65.js +0 -65
- package/989caea2.js +0 -505
- package/99b984d1.js +0 -237
- package/9e5f02d6.js +0 -19104
- package/a40faea7.js +0 -11624
- package/abac9104.js +0 -1536
- package/af2f19b3.js +0 -819
- package/af5ee3de.js +0 -268
- package/b24707c2.js +0 -48428
- package/b68f8b69.js +0 -1276
- package/ba68ba65.js +0 -391
- package/bafb8599.js +0 -319
- package/bba60c35.js +0 -2501
- package/bd7c2a8e.js +0 -1089
- package/c71dadea.js +0 -455
- package/d05c1762.js +0 -933
- package/d073ab24.js +0 -134353
- package/d838cd10.js +0 -769
- package/dc36a6eb.js +0 -796
- package/ed143450.js +0 -1284
- package/ee8ec8f2.js +0 -2284
- package/f6755210.js +0 -1269
- package/f9637058.js +0 -16
- package/fba4c8e4.js +0 -447
- package/index.js +0 -5
|
@@ -0,0 +1,633 @@
|
|
|
1
|
+
import { default as Form } from "antd/es/form";
|
|
2
|
+
import { default as Input } from "antd/es/input";
|
|
3
|
+
import { trans, getCalendarLocale } from "../../i18n/comps";
|
|
4
|
+
import { createRef, useContext, useRef, useState, useEffect } from "react";
|
|
5
|
+
import dayjs from "dayjs";
|
|
6
|
+
import FullCalendar from "@fullcalendar/react";
|
|
7
|
+
import resourceTimelinePlugin from "@fullcalendar/resource-timeline";
|
|
8
|
+
import resourceTimeGridPlugin from "@fullcalendar/resource-timegrid";
|
|
9
|
+
import adaptivePlugin from "@fullcalendar/adaptive";
|
|
10
|
+
import dayGridPlugin from "@fullcalendar/daygrid";
|
|
11
|
+
import multiMonthPlugin from '@fullcalendar/multimonth';
|
|
12
|
+
import timeGridPlugin from "@fullcalendar/timegrid";
|
|
13
|
+
import interactionPlugin from "@fullcalendar/interaction";
|
|
14
|
+
import listPlugin from "@fullcalendar/list";
|
|
15
|
+
import allLocales from "@fullcalendar/core/locales-all";
|
|
16
|
+
import { EventContentArg, DateSelectArg } from "@fullcalendar/core";
|
|
17
|
+
import momentPlugin from "@fullcalendar/moment";
|
|
18
|
+
|
|
19
|
+
import ErrorBoundary from "./errorBoundary";
|
|
20
|
+
|
|
21
|
+
import {
|
|
22
|
+
isValidColor,
|
|
23
|
+
NameConfig,
|
|
24
|
+
NameConfigHidden,
|
|
25
|
+
BoolControl,
|
|
26
|
+
UICompBuilder,
|
|
27
|
+
withDefault,
|
|
28
|
+
withExposingConfigs,
|
|
29
|
+
withMethodExposing,
|
|
30
|
+
NumberControl,
|
|
31
|
+
StringControl,
|
|
32
|
+
hiddenPropertyView,
|
|
33
|
+
ChangeEventHandlerControl,
|
|
34
|
+
// DragEventHandlerControl,
|
|
35
|
+
Section,
|
|
36
|
+
sectionNames,
|
|
37
|
+
dropdownControl,
|
|
38
|
+
styleControl,
|
|
39
|
+
ThemeContext,
|
|
40
|
+
CalendarStyle,
|
|
41
|
+
DateParser,
|
|
42
|
+
CustomModal,
|
|
43
|
+
jsonValueExposingStateControl,
|
|
44
|
+
CalendarDeleteIcon,
|
|
45
|
+
Tooltip,
|
|
46
|
+
} from "lowcoder-sdk";
|
|
47
|
+
|
|
48
|
+
import {
|
|
49
|
+
DefaultWithFreeViewOptions,
|
|
50
|
+
DefaultWithPremiumViewOptions,
|
|
51
|
+
FirstDayOptions,
|
|
52
|
+
Wrapper,
|
|
53
|
+
Event,
|
|
54
|
+
Remove,
|
|
55
|
+
EventType,
|
|
56
|
+
defaultData,
|
|
57
|
+
ViewType,
|
|
58
|
+
buttonText,
|
|
59
|
+
headerToolbar,
|
|
60
|
+
views,
|
|
61
|
+
slotLabelFormat,
|
|
62
|
+
slotLabelFormatWeek,
|
|
63
|
+
slotLabelFormatMonth,
|
|
64
|
+
viewClassNames,
|
|
65
|
+
FormWrapper,
|
|
66
|
+
resourcesDefaultData,
|
|
67
|
+
resourcesEventsDefaultData,
|
|
68
|
+
resourceTimeLineHeaderToolbar,
|
|
69
|
+
resourceTimeGridHeaderToolbar,
|
|
70
|
+
} from "./calendarConstants";
|
|
71
|
+
|
|
72
|
+
const childrenMap = {
|
|
73
|
+
events: jsonValueExposingStateControl("events", defaultData),
|
|
74
|
+
resourcesEvents: jsonValueExposingStateControl("resourcesEvents", resourcesEventsDefaultData),
|
|
75
|
+
resources: jsonValueExposingStateControl("resources", resourcesDefaultData),
|
|
76
|
+
resourceName: withDefault(StringControl, trans("calendar.resourcesDefault")),
|
|
77
|
+
onEvent: ChangeEventHandlerControl,
|
|
78
|
+
// onDropEvent: DragEventHandlerControl,
|
|
79
|
+
editable: withDefault(BoolControl, true),
|
|
80
|
+
showEventTime: withDefault(BoolControl, true),
|
|
81
|
+
showWeekends: withDefault(BoolControl, true),
|
|
82
|
+
showAllDay: withDefault(BoolControl, true),
|
|
83
|
+
defaultDate: withDefault(StringControl, "{{ new Date() }}"),
|
|
84
|
+
firstDay: dropdownControl(FirstDayOptions, "1"),
|
|
85
|
+
dayMaxEvents: withDefault(NumberControl, 2),
|
|
86
|
+
eventMaxStack: withDefault(NumberControl, 0),
|
|
87
|
+
style: styleControl(CalendarStyle),
|
|
88
|
+
licenseKey: withDefault( StringControl, "" ),
|
|
89
|
+
currentFreeView: dropdownControl(DefaultWithFreeViewOptions, "timeGridWeek"),
|
|
90
|
+
currentPremiumView: dropdownControl(DefaultWithPremiumViewOptions, "resourceTimelineDay"),
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
let CalendarBasicComp = (function () {
|
|
94
|
+
return new UICompBuilder(childrenMap, (props: {
|
|
95
|
+
events: any;
|
|
96
|
+
resourcesEvents: any;
|
|
97
|
+
resources: any;
|
|
98
|
+
resourceName : string
|
|
99
|
+
onEvent?: any;
|
|
100
|
+
// onDropEvent?: any;
|
|
101
|
+
editable?: boolean;
|
|
102
|
+
showEventTime?: boolean;
|
|
103
|
+
showWeekends?: boolean;
|
|
104
|
+
showAllDay?: boolean;
|
|
105
|
+
defaultDate?: string;
|
|
106
|
+
firstDay?: string;
|
|
107
|
+
dayMaxEvents?: number;
|
|
108
|
+
eventMaxStack?: number;
|
|
109
|
+
style: any;
|
|
110
|
+
licenseKey?: string;
|
|
111
|
+
licensed?: boolean;
|
|
112
|
+
currentFreeView?: string;
|
|
113
|
+
currentPremiumView?: string;
|
|
114
|
+
}) => {
|
|
115
|
+
|
|
116
|
+
const theme = useContext(ThemeContext);
|
|
117
|
+
const ref = createRef<HTMLDivElement>();
|
|
118
|
+
const editEvent = useRef<EventType>();
|
|
119
|
+
const [form] = Form.useForm();
|
|
120
|
+
const [left, setLeft] = useState<number | undefined>(undefined);
|
|
121
|
+
const [licensed, setLicensed] = useState<boolean>(props.licenseKey !== "");
|
|
122
|
+
|
|
123
|
+
useEffect(() => {
|
|
124
|
+
setLicensed(props.licenseKey !== "");
|
|
125
|
+
}, [props.licenseKey]);
|
|
126
|
+
|
|
127
|
+
let currentView = licensed ? props.currentPremiumView : props.currentFreeView;
|
|
128
|
+
let currentEvents = currentView == "resourceTimelineDay" || currentView == "resourceTimeGridDay" ? props.resourcesEvents : props.events;
|
|
129
|
+
|
|
130
|
+
console.log("currentEvents", currentEvents);
|
|
131
|
+
|
|
132
|
+
// we use one central stack of events for all views
|
|
133
|
+
let events = Array.isArray(currentEvents.value) ? currentEvents.value.map((item: EventType) => {
|
|
134
|
+
return {
|
|
135
|
+
title: item.title,
|
|
136
|
+
id: item.id,
|
|
137
|
+
start: dayjs(item.start, DateParser).format(),
|
|
138
|
+
end: dayjs(item.end, DateParser).format(),
|
|
139
|
+
allDay: item.allDay,
|
|
140
|
+
resourceId: item.resourceId ? item.resourceId : null,
|
|
141
|
+
color: isValidColor(item.color || "") ? item.color : theme?.theme?.primary,
|
|
142
|
+
...(item.groupId ? { groupId: item.groupId } : {}),
|
|
143
|
+
};
|
|
144
|
+
}) : [currentEvents.value];
|
|
145
|
+
|
|
146
|
+
const resources = props.resources.value;
|
|
147
|
+
|
|
148
|
+
// list all plugins for Fullcalendar
|
|
149
|
+
const plugins = [
|
|
150
|
+
dayGridPlugin,
|
|
151
|
+
timeGridPlugin,
|
|
152
|
+
interactionPlugin,
|
|
153
|
+
listPlugin,
|
|
154
|
+
momentPlugin,
|
|
155
|
+
resourceTimelinePlugin,
|
|
156
|
+
resourceTimeGridPlugin,
|
|
157
|
+
adaptivePlugin,
|
|
158
|
+
multiMonthPlugin,
|
|
159
|
+
];
|
|
160
|
+
|
|
161
|
+
// filter out premium plugins if not licensed
|
|
162
|
+
const filteredPlugins = plugins.filter((plugin) => {
|
|
163
|
+
if (!licensed) {
|
|
164
|
+
return ![resourceTimelinePlugin, resourceTimeGridPlugin, adaptivePlugin].includes(plugin);
|
|
165
|
+
}
|
|
166
|
+
return true;
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
const toolBar = (defaultView: any) => {
|
|
170
|
+
switch (defaultView) {
|
|
171
|
+
case "resourceTimelineDay":
|
|
172
|
+
return resourceTimeLineHeaderToolbar;
|
|
173
|
+
break;
|
|
174
|
+
case "resourceTimeGridDay":
|
|
175
|
+
return resourceTimeGridHeaderToolbar;
|
|
176
|
+
break;
|
|
177
|
+
default:
|
|
178
|
+
return headerToolbar;
|
|
179
|
+
break;
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
const [currentSlotLabelFormat, setCurrentSlotLabelFormat] = useState(slotLabelFormat);
|
|
185
|
+
|
|
186
|
+
const handleDatesSet = (arg: { view: { type: any; }; }) => {
|
|
187
|
+
switch (arg.view.type) {
|
|
188
|
+
case "resourceTimelineDay":
|
|
189
|
+
setCurrentSlotLabelFormat(slotLabelFormat);
|
|
190
|
+
break;
|
|
191
|
+
case "resourceTimelineWeek":
|
|
192
|
+
setCurrentSlotLabelFormat(slotLabelFormatWeek);
|
|
193
|
+
break;
|
|
194
|
+
case "resourceTimelineMonth":
|
|
195
|
+
setCurrentSlotLabelFormat(slotLabelFormatMonth);
|
|
196
|
+
break;
|
|
197
|
+
default:
|
|
198
|
+
setCurrentSlotLabelFormat(slotLabelFormat);
|
|
199
|
+
break;
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
let initialDate: string | undefined;
|
|
204
|
+
|
|
205
|
+
try {
|
|
206
|
+
initialDate = new Date(props.defaultDate || Date.now()).toISOString();
|
|
207
|
+
} catch (error) {
|
|
208
|
+
initialDate = undefined;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
let {
|
|
212
|
+
showEventTime,
|
|
213
|
+
showWeekends,
|
|
214
|
+
showAllDay,
|
|
215
|
+
dayMaxEvents,
|
|
216
|
+
eventMaxStack,
|
|
217
|
+
style,
|
|
218
|
+
firstDay,
|
|
219
|
+
editable,
|
|
220
|
+
licenseKey,
|
|
221
|
+
resourceName,
|
|
222
|
+
} = props;
|
|
223
|
+
|
|
224
|
+
function renderEventContent(eventInfo: EventContentArg) {
|
|
225
|
+
const isList = eventInfo.view.type === "listWeek";
|
|
226
|
+
let sizeClass = "";
|
|
227
|
+
if (
|
|
228
|
+
[ViewType.WEEK, ViewType.DAY].includes(eventInfo.view.type as ViewType)
|
|
229
|
+
) {
|
|
230
|
+
const duration = dayjs(eventInfo.event.end).diff(
|
|
231
|
+
dayjs(eventInfo.event.start),
|
|
232
|
+
"minutes"
|
|
233
|
+
);
|
|
234
|
+
if (duration <= 30 || eventInfo.event.allDay) {
|
|
235
|
+
sizeClass = "small";
|
|
236
|
+
} else if (duration <= 60) {
|
|
237
|
+
sizeClass = "middle";
|
|
238
|
+
} else {
|
|
239
|
+
sizeClass = "large";
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
const stateClass =
|
|
243
|
+
dayjs().isAfter(dayjs(eventInfo.event.end)) &&
|
|
244
|
+
(eventInfo.view.type as ViewType) !== ViewType.MONTH
|
|
245
|
+
? "past"
|
|
246
|
+
: "";
|
|
247
|
+
|
|
248
|
+
return (
|
|
249
|
+
<Event
|
|
250
|
+
className={`event ${sizeClass} ${stateClass}`}
|
|
251
|
+
$bg={eventInfo.backgroundColor}
|
|
252
|
+
theme={theme?.theme}
|
|
253
|
+
$isList={isList}
|
|
254
|
+
$allDay={Boolean(showAllDay)}
|
|
255
|
+
$style={props.style}
|
|
256
|
+
>
|
|
257
|
+
<div className="event-time">{eventInfo.timeText}</div>
|
|
258
|
+
<div className="event-title">{eventInfo.event.title}</div>
|
|
259
|
+
<Remove
|
|
260
|
+
$isList={isList}
|
|
261
|
+
className="event-remove"
|
|
262
|
+
onClick={(e) => {
|
|
263
|
+
e.stopPropagation();
|
|
264
|
+
props.onEvent("change");
|
|
265
|
+
const event = events.filter(
|
|
266
|
+
(item: EventType) => item.id !== eventInfo.event.id
|
|
267
|
+
);
|
|
268
|
+
props.events.onChange(event);
|
|
269
|
+
}}
|
|
270
|
+
onMouseDown={(e) => {
|
|
271
|
+
e.stopPropagation();
|
|
272
|
+
e.preventDefault();
|
|
273
|
+
}}
|
|
274
|
+
>
|
|
275
|
+
<CalendarDeleteIcon />
|
|
276
|
+
</Remove>
|
|
277
|
+
</Event>
|
|
278
|
+
);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
const handleDbClick = () => {
|
|
282
|
+
const event = props.events.value.find(
|
|
283
|
+
(item: EventType) => item.id === editEvent.current?.id
|
|
284
|
+
) as EventType;
|
|
285
|
+
if (!editable || !editEvent.current) {
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
if (event) {
|
|
289
|
+
const { title, groupId, color, id } = event;
|
|
290
|
+
const eventInfo = {
|
|
291
|
+
title,
|
|
292
|
+
groupId,
|
|
293
|
+
color,
|
|
294
|
+
id,
|
|
295
|
+
};
|
|
296
|
+
showModal(eventInfo, true);
|
|
297
|
+
} else {
|
|
298
|
+
showModal(editEvent.current, false);
|
|
299
|
+
}
|
|
300
|
+
};
|
|
301
|
+
|
|
302
|
+
const handleCreate = (info: DateSelectArg) => {
|
|
303
|
+
const event = {
|
|
304
|
+
allDay: info.allDay,
|
|
305
|
+
start: info.startStr,
|
|
306
|
+
end: info.endStr,
|
|
307
|
+
};
|
|
308
|
+
const view = info.view.type as ViewType;
|
|
309
|
+
const duration = dayjs(info.end).diff(dayjs(info.start), "minutes");
|
|
310
|
+
const singleClick =
|
|
311
|
+
(view === ViewType.MONTH && duration === 1440) ||
|
|
312
|
+
([ViewType.WEEK, ViewType.DAY].includes(view) && duration === 30) ||
|
|
313
|
+
(info.allDay && duration === 1440);
|
|
314
|
+
if (singleClick) {
|
|
315
|
+
editEvent.current = event;
|
|
316
|
+
setTimeout(() => {
|
|
317
|
+
editEvent.current = undefined;
|
|
318
|
+
}, 500);
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
321
|
+
showModal(event, false);
|
|
322
|
+
};
|
|
323
|
+
|
|
324
|
+
const showModal = (event: EventType, ifEdit: boolean) => {
|
|
325
|
+
const modalTitle = ifEdit
|
|
326
|
+
? trans("calendar.editEvent")
|
|
327
|
+
: trans("calendar.creatEvent");
|
|
328
|
+
form && form.setFieldsValue(event);
|
|
329
|
+
const eventId = editEvent.current?.id;
|
|
330
|
+
CustomModal.confirm({
|
|
331
|
+
title: modalTitle,
|
|
332
|
+
content: (
|
|
333
|
+
<FormWrapper form={form}>
|
|
334
|
+
<Form.Item
|
|
335
|
+
label={
|
|
336
|
+
<Tooltip title={trans("calendar.eventIdTooltip")}>
|
|
337
|
+
{trans("calendar.eventId")}
|
|
338
|
+
</Tooltip>
|
|
339
|
+
}
|
|
340
|
+
name="id"
|
|
341
|
+
rules={[
|
|
342
|
+
{ required: true, message: trans("calendar.eventIdRequire") },
|
|
343
|
+
]}
|
|
344
|
+
>
|
|
345
|
+
<Input />
|
|
346
|
+
</Form.Item>
|
|
347
|
+
<Form.Item
|
|
348
|
+
label={trans("calendar.eventName")}
|
|
349
|
+
name="title"
|
|
350
|
+
rules={[
|
|
351
|
+
{ required: true, message: trans("calendar.eventNameRequire") },
|
|
352
|
+
]}
|
|
353
|
+
>
|
|
354
|
+
<Input />
|
|
355
|
+
</Form.Item>
|
|
356
|
+
<Form.Item label={trans("calendar.eventColor")} name="color">
|
|
357
|
+
<Input />
|
|
358
|
+
</Form.Item>
|
|
359
|
+
<Form.Item
|
|
360
|
+
label={
|
|
361
|
+
<Tooltip title={trans("calendar.groupIdTooltip")}>
|
|
362
|
+
{trans("calendar.eventGroupId")}
|
|
363
|
+
</Tooltip>
|
|
364
|
+
}
|
|
365
|
+
name="groupId"
|
|
366
|
+
>
|
|
367
|
+
<Input />
|
|
368
|
+
</Form.Item>
|
|
369
|
+
</FormWrapper>
|
|
370
|
+
),
|
|
371
|
+
onConfirm: () => {
|
|
372
|
+
form.submit();
|
|
373
|
+
return form.validateFields().then(() => {
|
|
374
|
+
const { id, groupId, color, title = "" } = form.getFieldsValue();
|
|
375
|
+
const idExist = props.events.value.findIndex(
|
|
376
|
+
(item: EventType) => item.id === id
|
|
377
|
+
);
|
|
378
|
+
if (idExist > -1 && id !== eventId) {
|
|
379
|
+
form.setFields([
|
|
380
|
+
{ name: "id", errors: [trans("calendar.eventIdExist")] },
|
|
381
|
+
]);
|
|
382
|
+
throw new Error();
|
|
383
|
+
}
|
|
384
|
+
if (ifEdit) {
|
|
385
|
+
const changeEvents = props.events.value.map((item: EventType) => {
|
|
386
|
+
if (item.id === eventId) {
|
|
387
|
+
return {
|
|
388
|
+
...item,
|
|
389
|
+
title,
|
|
390
|
+
id,
|
|
391
|
+
...(groupId !== undefined ? { groupId } : null),
|
|
392
|
+
...(color !== undefined ? { color } : null),
|
|
393
|
+
};
|
|
394
|
+
} else {
|
|
395
|
+
return item;
|
|
396
|
+
}
|
|
397
|
+
});
|
|
398
|
+
props.events.onChange(changeEvents);
|
|
399
|
+
} else {
|
|
400
|
+
const createInfo = {
|
|
401
|
+
allDay: event.allDay,
|
|
402
|
+
start: event.start,
|
|
403
|
+
end: event.end,
|
|
404
|
+
id,
|
|
405
|
+
title,
|
|
406
|
+
...(groupId !== undefined ? { groupId } : null),
|
|
407
|
+
...(color !== undefined ? { color } : null),
|
|
408
|
+
};
|
|
409
|
+
props.events.onChange([...props.events.value, createInfo]);
|
|
410
|
+
}
|
|
411
|
+
props.onEvent("change");
|
|
412
|
+
form.resetFields();
|
|
413
|
+
}); //small change
|
|
414
|
+
},
|
|
415
|
+
onCancel: () => {
|
|
416
|
+
form.resetFields();
|
|
417
|
+
},
|
|
418
|
+
});
|
|
419
|
+
};
|
|
420
|
+
|
|
421
|
+
return (
|
|
422
|
+
<Wrapper
|
|
423
|
+
ref={ref}
|
|
424
|
+
$editable={editable}
|
|
425
|
+
$style={style}
|
|
426
|
+
$theme={theme?.theme}
|
|
427
|
+
onDoubleClick={handleDbClick}
|
|
428
|
+
$left={left}
|
|
429
|
+
key={initialDate ? currentView + initialDate : currentView}
|
|
430
|
+
>
|
|
431
|
+
<ErrorBoundary>
|
|
432
|
+
<FullCalendar
|
|
433
|
+
slotEventOverlap={false}
|
|
434
|
+
events={ events }
|
|
435
|
+
dayHeaders={true}
|
|
436
|
+
dayHeaderFormat={{ weekday: 'short', month: 'numeric', day: 'numeric', omitCommas: true }}
|
|
437
|
+
expandRows={true}
|
|
438
|
+
multiMonthMinWidth={250}
|
|
439
|
+
nowIndicator={true}
|
|
440
|
+
height={"100%"}
|
|
441
|
+
locale={getCalendarLocale()}
|
|
442
|
+
locales={allLocales}
|
|
443
|
+
firstDay={Number(firstDay)}
|
|
444
|
+
plugins={filteredPlugins}
|
|
445
|
+
headerToolbar={toolBar(currentView)}
|
|
446
|
+
resourceAreaHeaderContent={resourceName}
|
|
447
|
+
|
|
448
|
+
buttonText={buttonText}
|
|
449
|
+
schedulerLicenseKey={licenseKey}
|
|
450
|
+
views={views}
|
|
451
|
+
resources={ currentView == "resourceTimelineDay" || currentView == "resourceTimeGridDay" ? resources : [] }
|
|
452
|
+
eventClassNames={() => (!showEventTime ? "no-time" : "")}
|
|
453
|
+
slotLabelFormat={currentSlotLabelFormat}
|
|
454
|
+
viewClassNames={viewClassNames}
|
|
455
|
+
moreLinkText={trans("calendar.more")}
|
|
456
|
+
initialDate={initialDate}
|
|
457
|
+
initialView={currentView}
|
|
458
|
+
editable={editable}
|
|
459
|
+
selectable={editable}
|
|
460
|
+
datesSet={handleDatesSet}
|
|
461
|
+
selectMirror={false}
|
|
462
|
+
displayEventTime={showEventTime}
|
|
463
|
+
dayMaxEvents={dayMaxEvents}
|
|
464
|
+
eventMaxStack={eventMaxStack || undefined}
|
|
465
|
+
weekends={showWeekends}
|
|
466
|
+
allDaySlot={showAllDay}
|
|
467
|
+
eventContent={renderEventContent}
|
|
468
|
+
select={(info) => handleCreate(info)}
|
|
469
|
+
eventClick={(info) => {
|
|
470
|
+
const event = events.find(
|
|
471
|
+
(item: EventType) => item.id === info.event.id
|
|
472
|
+
);
|
|
473
|
+
editEvent.current = event;
|
|
474
|
+
setTimeout(() => {
|
|
475
|
+
editEvent.current = undefined;
|
|
476
|
+
}, 500);
|
|
477
|
+
}}
|
|
478
|
+
moreLinkClick={(info) => {
|
|
479
|
+
let left = 0;
|
|
480
|
+
const ele = info.jsEvent.target as HTMLElement;
|
|
481
|
+
if (info.view.type === ViewType.DAY) {
|
|
482
|
+
if (info.allDay) {
|
|
483
|
+
left = ele.offsetParent?.parentElement?.offsetLeft || 0;
|
|
484
|
+
} else {
|
|
485
|
+
left = ele.parentElement?.offsetLeft || 0;
|
|
486
|
+
}
|
|
487
|
+
} else {
|
|
488
|
+
if (info.allDay) {
|
|
489
|
+
left =
|
|
490
|
+
ele.offsetParent?.parentElement?.parentElement?.offsetLeft ||
|
|
491
|
+
0;
|
|
492
|
+
} else {
|
|
493
|
+
left =
|
|
494
|
+
ele.offsetParent?.parentElement?.parentElement?.parentElement
|
|
495
|
+
?.offsetLeft || 0;
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
setLeft(left);
|
|
499
|
+
}}
|
|
500
|
+
eventsSet={(info) => {
|
|
501
|
+
let needChange = false;
|
|
502
|
+
let changeEvents: EventType[] = [];
|
|
503
|
+
info.forEach((item) => {
|
|
504
|
+
const event = events.find((i: EventType) => i.id === item.id);
|
|
505
|
+
const start = dayjs(item.start, DateParser).format();
|
|
506
|
+
const end = dayjs(item.end, DateParser).format();
|
|
507
|
+
if (
|
|
508
|
+
start !== event?.start ||
|
|
509
|
+
end !== event?.end ||
|
|
510
|
+
!!item.allDay !== !!event?.allDay
|
|
511
|
+
) {
|
|
512
|
+
needChange = true;
|
|
513
|
+
changeEvents.push({
|
|
514
|
+
...event,
|
|
515
|
+
allDay: item.allDay,
|
|
516
|
+
start: item.startStr,
|
|
517
|
+
end: item.endStr,
|
|
518
|
+
});
|
|
519
|
+
} else {
|
|
520
|
+
changeEvents.push(event);
|
|
521
|
+
}
|
|
522
|
+
});
|
|
523
|
+
if (needChange) {
|
|
524
|
+
props.onEvent("change");
|
|
525
|
+
}
|
|
526
|
+
}}
|
|
527
|
+
eventDragStop={(info) => {
|
|
528
|
+
if (info.view) {
|
|
529
|
+
// props.onDropEvent("dropEvent");
|
|
530
|
+
}
|
|
531
|
+
}}
|
|
532
|
+
/>
|
|
533
|
+
</ErrorBoundary>
|
|
534
|
+
</Wrapper>
|
|
535
|
+
);
|
|
536
|
+
})
|
|
537
|
+
.setPropertyViewFn((children: {
|
|
538
|
+
|
|
539
|
+
events: { propertyView: (arg0: {}) => any; };
|
|
540
|
+
resourcesEvents: { propertyView: (arg0: {}) => any; };
|
|
541
|
+
resources: { propertyView: (arg0: {}) => any; };
|
|
542
|
+
resourceName: { propertyView: (arg0: {}) => any; };
|
|
543
|
+
onEvent: { propertyView: ({title}?: {title?: string}) => any; };
|
|
544
|
+
// onDropEvent: { propertyView: ({title}?: {title?: string}) => any; };
|
|
545
|
+
editable: { propertyView: (arg0: { label: string; }) => any; };
|
|
546
|
+
showEventTime: { propertyView: (arg0: { label: string; tooltip: string; }) => any; };
|
|
547
|
+
showWeekends: { propertyView: (arg0: { label: string; }) => any; };
|
|
548
|
+
showAllDay: { propertyView: (arg0: { label: string; tooltip: string; }) => any; };
|
|
549
|
+
defaultDate: { propertyView: (arg0: { label: string; tooltip: string; }) => any; };
|
|
550
|
+
firstDay: { propertyView: (arg0: { label: string; }) => any; };
|
|
551
|
+
dayMaxEvents: { propertyView: (arg0: { label: string; tooltip: string; }) => any; };
|
|
552
|
+
eventMaxStack: { propertyView: (arg0: { label: string; tooltip: string; }) => any; };
|
|
553
|
+
currentFreeView: { propertyView: (arg0: { label: string; tooltip: string; }) => any; };
|
|
554
|
+
currentPremiumView: { propertyView: (arg0: { label: string; tooltip: string; }) => any; };
|
|
555
|
+
style: { getPropertyView: () => any; };
|
|
556
|
+
licenseKey: { getView: () => any; propertyView: (arg0: { label: string; }) => any; };
|
|
557
|
+
}) => {
|
|
558
|
+
|
|
559
|
+
const license = children.licenseKey.getView();
|
|
560
|
+
|
|
561
|
+
return (
|
|
562
|
+
<>
|
|
563
|
+
<Section name={sectionNames.basic}>
|
|
564
|
+
{children.defaultDate.propertyView({ label: trans("calendar.defaultDate"), tooltip: trans("calendar.defaultDateTooltip"), })}
|
|
565
|
+
{children.events.propertyView({label: trans("calendar.events")})}
|
|
566
|
+
{license == "" ? null : children.resourcesEvents.propertyView({label: trans("calendar.resourcesEvents")})}
|
|
567
|
+
</Section>
|
|
568
|
+
{ license != "" &&
|
|
569
|
+
<Section name={trans("calendar.resources")}>
|
|
570
|
+
{children.resources.propertyView({label: trans("calendar.resources")})}
|
|
571
|
+
{children.resourceName.propertyView({label: trans("calendar.resourcesName")})}
|
|
572
|
+
</Section>
|
|
573
|
+
}
|
|
574
|
+
<Section name={sectionNames.interaction}>
|
|
575
|
+
{hiddenPropertyView(children)}
|
|
576
|
+
<div style={{display: 'flex', flexDirection: 'column', gap: '8px'}}>
|
|
577
|
+
{children.onEvent.propertyView()}
|
|
578
|
+
</div>
|
|
579
|
+
<div style={{display: 'flex', flexDirection: 'column', gap: '8px'}}>
|
|
580
|
+
{/* {children.onDropEvent.propertyView({title: trans("calendar.dragDropEventHandlers")})} */}
|
|
581
|
+
</div>
|
|
582
|
+
{children.editable.propertyView({ label: trans("calendar.editable"), })}
|
|
583
|
+
</Section>
|
|
584
|
+
<Section name={sectionNames.advanced}>
|
|
585
|
+
{children.showEventTime.propertyView({ label: trans("calendar.showEventTime"), tooltip: trans("calendar.showEventTimeTooltip"), })}
|
|
586
|
+
{children.showWeekends.propertyView({ label: trans("calendar.showWeekends"), })}
|
|
587
|
+
{children.showAllDay.propertyView({ label: trans("calendar.showAllDay"), tooltip: trans("calendar.showAllDayTooltip"), })}
|
|
588
|
+
{children.dayMaxEvents.propertyView({ label: trans("calendar.dayMaxEvents"), tooltip: trans("calendar.dayMaxEventsTooltip"), })}
|
|
589
|
+
{children.eventMaxStack.propertyView({ label: trans("calendar.eventMaxStack"), tooltip: trans("calendar.eventMaxStackTooltip"), })}
|
|
590
|
+
</Section>
|
|
591
|
+
<Section name={sectionNames.layout}>
|
|
592
|
+
{children.licenseKey.propertyView({ label: trans("calendar.license"), tooltip: trans("calendar.licenseTooltip"), })}
|
|
593
|
+
{license == ""
|
|
594
|
+
? children.currentFreeView.propertyView({ label: trans("calendar.defaultView"), tooltip: trans("calendar.defaultViewTooltip"), })
|
|
595
|
+
: children.currentPremiumView.propertyView({ label: trans("calendar.defaultView"), tooltip: trans("calendar.defaultViewTooltip"), })}
|
|
596
|
+
{children.firstDay.propertyView({ label: trans("calendar.startWeek"), })}
|
|
597
|
+
</Section>
|
|
598
|
+
<Section name={sectionNames.style}>
|
|
599
|
+
{children.style.getPropertyView()}
|
|
600
|
+
</Section>
|
|
601
|
+
</>
|
|
602
|
+
);
|
|
603
|
+
})
|
|
604
|
+
.build();
|
|
605
|
+
})();
|
|
606
|
+
|
|
607
|
+
CalendarBasicComp = class extends CalendarBasicComp {
|
|
608
|
+
override autoHeight(): boolean {
|
|
609
|
+
return false;
|
|
610
|
+
}
|
|
611
|
+
};
|
|
612
|
+
|
|
613
|
+
const TmpCalendarComp = withExposingConfigs(CalendarBasicComp, [
|
|
614
|
+
new NameConfig("events", trans("calendar.events")),
|
|
615
|
+
new NameConfig("resourcesEvents", trans("calendar.resourcesEvents")),
|
|
616
|
+
new NameConfig("resources", trans("calendar.resources")),
|
|
617
|
+
NameConfigHidden,
|
|
618
|
+
]);
|
|
619
|
+
|
|
620
|
+
export const CalendarComp = withMethodExposing(TmpCalendarComp, [
|
|
621
|
+
{
|
|
622
|
+
method: {
|
|
623
|
+
name: "setCalendarView",
|
|
624
|
+
description: "timeGridWeek || timeGridDay || dayGridMonth || listWeek || resourceTimelineDay || resourceTimeGridDay || resourceTimelineWeek || resourceTimelineMonth",
|
|
625
|
+
params: [{ name: "viewType", type: "string" }],
|
|
626
|
+
},
|
|
627
|
+
execute: (comp, values) => {
|
|
628
|
+
const viewType = values[0] as string;
|
|
629
|
+
viewType == "" ? viewType : "timeGridWeek";
|
|
630
|
+
return comp.children.licenseKey.getView() == "" ? comp.children.defaultFreeView.dispatchChangeValueAction(viewType) : comp.children.defaultPremiumView.dispatchChangeValueAction(viewType);
|
|
631
|
+
}
|
|
632
|
+
},
|
|
633
|
+
]);
|