lowcoder-comps 0.0.31 → 0.0.33
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/00bb478a.js +1102 -0
- package/02bef5a4.js +505 -0
- package/057d2a44.js +1127 -0
- package/0964fcc6.js +34 -0
- package/14220e98.js +1276 -0
- package/1c074fe4.js +25 -0
- package/250a6954.js +804 -0
- package/256b619e.js +92 -0
- package/2cd27cf0.js +2501 -0
- package/2f064957.js +64 -0
- package/2ff2c7a6.js +6 -0
- package/2ff7471d.js +9 -0
- package/30c4916b.js +8 -0
- package/36ec7270.js +915 -0
- package/38c14832.js +960 -0
- package/3ae34bed.js +819 -0
- package/3e2939fa.js +237 -0
- package/3f5f874f.js +86 -0
- package/3fb86fb9.js +447 -0
- package/415177f9.js +1579 -0
- package/47848c42.js +11636 -0
- package/4c6a0ece.js +162535 -0
- package/4db8e48b.js +2284 -0
- package/531065f1.js +1089 -0
- package/5a398ea8.js +881 -0
- package/5ab1614c.js +268 -0
- package/65bbb6ae.js +1536 -0
- package/777cd15c.js +48428 -0
- package/7dacfa82.js +220 -0
- package/800cf0d0.js +796 -0
- package/92e85b65.js +65 -0
- package/93e9bd3a.js +391 -0
- package/98622dfa.js +16582 -0
- package/a2e74e62.js +2967 -0
- package/a61c3bd3.js +5 -0
- package/b8f48ff4.js +769 -0
- package/bd0f5f65.js +319 -0
- package/bf4428f5.js +1269 -0
- package/cb1972f7.js +455 -0
- package/dfc10c94.js +818 -0
- package/ed2c9753.js +208 -0
- package/ef2833e6.js +927 -0
- package/f9637058.js +16 -0
- package/f9e72519.js +1284 -0
- package/fe063d15.js +19339 -0
- package/index.js +5 -0
- package/package.json +30 -3
- package/README.md +0 -120
- package/index.html +0 -26
- package/index.tsx +0 -21
- package/jest.config.js +0 -6
- package/src/__test__/allComp.test.tsx +0 -61
- package/src/app-env.d.ts +0 -3
- package/src/comps/calendarComp/calendarComp.tsx +0 -633
- package/src/comps/calendarComp/calendarConstants.tsx +0 -1048
- package/src/comps/calendarComp/errorBoundary.tsx +0 -30
- package/src/comps/chartComp/chartComp.tsx +0 -442
- package/src/comps/chartComp/chartConfigs/barChartConfig.tsx +0 -51
- package/src/comps/chartComp/chartConfigs/cartesianAxisConfig.tsx +0 -307
- package/src/comps/chartComp/chartConfigs/chartUrls.tsx +0 -9
- package/src/comps/chartComp/chartConfigs/legendConfig.tsx +0 -55
- package/src/comps/chartComp/chartConfigs/lineChartConfig.tsx +0 -96
- package/src/comps/chartComp/chartConfigs/pieChartConfig.tsx +0 -83
- package/src/comps/chartComp/chartConfigs/scatterChartConfig.tsx +0 -62
- package/src/comps/chartComp/chartConstants.tsx +0 -299
- package/src/comps/chartComp/chartPropertyView.tsx +0 -235
- package/src/comps/chartComp/chartUtils.ts +0 -291
- package/src/comps/chartComp/reactEcharts/core.tsx +0 -194
- package/src/comps/chartComp/reactEcharts/index.ts +0 -21
- package/src/comps/chartComp/reactEcharts/types.ts +0 -76
- package/src/comps/chartComp/seriesComp.tsx +0 -119
- package/src/comps/imageEditorComp/imageEditorClass.tsx +0 -52
- package/src/comps/imageEditorComp/imageEditorConstants.tsx +0 -109
- package/src/comps/imageEditorComp/index.tsx +0 -184
- package/src/comps/mermaidComp/index.tsx +0 -44
- package/src/comps/mermaidComp/mermaid.tsx +0 -29
- package/src/global.ts +0 -1
- package/src/i18n/comps/index.tsx +0 -29
- package/src/i18n/comps/locales/en.ts +0 -163
- package/src/i18n/comps/locales/enObj.tsx +0 -198
- package/src/i18n/comps/locales/index.ts +0 -7
- package/src/i18n/comps/locales/types.tsx +0 -10
- package/src/i18n/comps/locales/zh.ts +0 -156
- package/src/i18n/comps/locales/zhObj.tsx +0 -4
- package/src/index.ts +0 -11
- package/tsconfig.json +0 -22
- package/vite.config.js +0 -10
|
@@ -1,633 +0,0 @@
|
|
|
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
|
-
]);
|