lowcoder-comps 0.0.7 → 0.0.8

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.
Files changed (79) hide show
  1. package/icons/icon-chart.svg +15 -0
  2. package/icons/icon-comp-calendar.svg +22 -0
  3. package/index.html +26 -0
  4. package/index.tsx +19 -0
  5. package/jest.config.js +5 -0
  6. package/package/012a06bb.js +34 -0
  7. package/package/06481cb7.js +1060 -0
  8. package/package/0c8b29d5.js +6 -0
  9. package/package/114884df.js +805 -0
  10. package/package/1264ddb2.js +194 -0
  11. package/package/1cee31ec.js +1095 -0
  12. package/package/269c3ba3.js +46662 -0
  13. package/package/2a2c2e55.js +799 -0
  14. package/package/2b3ab1e4.js +98763 -0
  15. package/package/37590a81.js +967 -0
  16. package/package/3cd7980e.js +184 -0
  17. package/package/40112498.js +424 -0
  18. package/package/4b6e1d6f.js +24 -0
  19. package/package/4bc1082b.js +86 -0
  20. package/package/53e49f9b.js +1600 -0
  21. package/package/55bd5c26.js +266 -0
  22. package/package/591684c8.js +2071 -0
  23. package/package/6c000872.js +16 -0
  24. package/package/756addec.js +775 -0
  25. package/package/7668124e.js +8 -0
  26. package/package/79e8eeeb.js +949 -0
  27. package/package/926fbfec.js +91 -0
  28. package/package/945eefb3.js +2665 -0
  29. package/package/a35f148e.js +1228 -0
  30. package/package/a4d12a43.js +175 -0
  31. package/package/a60de5d1.js +804 -0
  32. package/package/a8dde1ea.js +589 -0
  33. package/package/b4148642.js +7 -0
  34. package/package/b7dd22a2.js +847 -0
  35. package/package/d4f3a2c4.js +18046 -0
  36. package/package/e0f479f3.js +91 -0
  37. package/package/eaa160c9.js +341 -0
  38. package/package/f1bfd8b5.js +311 -0
  39. package/package/f1f9ba79.js +900 -0
  40. package/package/fba61f63.js +2868 -0
  41. package/package/icons/icon-chart.svg +15 -0
  42. package/package/icons/icon-comp-calendar.svg +22 -0
  43. package/package/index.js +5 -0
  44. package/package/package.json +73 -0
  45. package/package.json +1 -4
  46. package/src/__test__/allComp.test.tsx +61 -0
  47. package/src/app-env.d.ts +3 -0
  48. package/src/comps/calendarComp/calendarComp.tsx +442 -0
  49. package/src/comps/calendarComp/calendarConstants.tsx +897 -0
  50. package/src/comps/chartComp/chartComp.tsx +249 -0
  51. package/src/comps/chartComp/chartConfigs/barChartConfig.tsx +51 -0
  52. package/src/comps/chartComp/chartConfigs/cartesianAxisConfig.tsx +307 -0
  53. package/src/comps/chartComp/chartConfigs/chartUrls.tsx +6 -0
  54. package/src/comps/chartComp/chartConfigs/legendConfig.tsx +55 -0
  55. package/src/comps/chartComp/chartConfigs/lineChartConfig.tsx +96 -0
  56. package/src/comps/chartComp/chartConfigs/pieChartConfig.tsx +83 -0
  57. package/src/comps/chartComp/chartConfigs/scatterChartConfig.tsx +62 -0
  58. package/src/comps/chartComp/chartConstants.tsx +243 -0
  59. package/src/comps/chartComp/chartPropertyView.tsx +161 -0
  60. package/src/comps/chartComp/chartUtils.ts +240 -0
  61. package/src/comps/chartComp/reactEcharts/core.tsx +187 -0
  62. package/src/comps/chartComp/reactEcharts/index.ts +20 -0
  63. package/src/comps/chartComp/reactEcharts/types.ts +70 -0
  64. package/src/comps/chartComp/seriesComp.tsx +119 -0
  65. package/src/comps/imageEditorComp/imageEditorClass.tsx +52 -0
  66. package/src/comps/imageEditorComp/imageEditorConstants.tsx +109 -0
  67. package/src/comps/imageEditorComp/index.tsx +184 -0
  68. package/src/comps/mermaidComp/index.tsx +44 -0
  69. package/src/comps/mermaidComp/mermaid.tsx +29 -0
  70. package/src/global.ts +1 -0
  71. package/src/i18n/comps/index.tsx +29 -0
  72. package/src/i18n/comps/locales/en.ts +142 -0
  73. package/src/i18n/comps/locales/enObj.tsx +120 -0
  74. package/src/i18n/comps/locales/index.ts +7 -0
  75. package/src/i18n/comps/locales/types.tsx +9 -0
  76. package/src/i18n/comps/locales/zh.ts +4 -0
  77. package/src/i18n/comps/locales/zhObj.tsx +4 -0
  78. package/src/index.ts +11 -0
  79. package/vite.config.js +10 -0
@@ -0,0 +1,15 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="48px" height="48px" viewBox="0 0 48 48" version="1.1">
2
+ <g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
3
+ <g transform="translate(6.000000, 11.500000)" stroke="#D7D9E0" stroke-linecap="round" stroke-width="2">
4
+ <line x1="-2.00715996e-17" y1="0.5" x2="36" y2="0.5"/>
5
+ <line x1="-2.00715996e-17" y1="8.5" x2="36" y2="8.5"/>
6
+ <line x1="2.70913881e-14" y1="16.5" x2="36" y2="16.5"/>
7
+ <line x1="2.70913881e-14" y1="24.5" x2="36" y2="24.5"/>
8
+ </g>
9
+ <g transform="translate(11.000000, 10.000000)" fill="#3377FF">
10
+ <path d="M11,0 L15,0 C15.5522847,-1.01453063e-16 16,0.44771525 16,1 L16,25 L16,25 L10,25 L10,1 C10,0.44771525 10.4477153,7.67586877e-16 11,0 Z"/>
11
+ <path d="M1,13 L5,13 C5.55228475,13 6,13.4477153 6,14 L6,25 L6,25 L0,25 L0,14 C-6.76353751e-17,13.4477153 0.44771525,13 1,13 Z"/>
12
+ <path d="M21,6 L25,6 C25.5522847,6 26,6.44771525 26,7 L26,25 L26,25 L20,25 L20,7 C20,6.44771525 20.4477153,6 21,6 Z"/>
13
+ </g>
14
+ </g>
15
+ </svg>
@@ -0,0 +1,22 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <svg width="48px" height="48px" viewBox="0 0 48 48" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
3
+ <g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
4
+ <g transform="translate(6.000000, 5.000000)">
5
+ <rect stroke="#D7D9E0" stroke-width="2" fill="#FFFFFF" x="1" y="4" width="34" height="30" rx="3"></rect>
6
+ <g transform="translate(5.000000, 14.000000)">
7
+ <rect fill="#3377FF" x="14" y="0" width="5" height="5" rx="1.5"></rect>
8
+ <rect fill="#8B8FA3" x="7" y="0" width="5" height="5" rx="1.5"></rect>
9
+ <rect fill="#3377FF" x="14" y="6" width="5" height="5" rx="1.5"></rect>
10
+ <rect fill="#8B8FA3" x="7" y="6" width="5" height="5" rx="1.5"></rect>
11
+ <rect fill="#8B8FA3" x="0" y="6" width="5" height="5" rx="1.5"></rect>
12
+ <rect fill="#8B8FA3" x="7" y="12" width="5" height="5" rx="1.5"></rect>
13
+ <rect fill="#8B8FA3" x="0" y="12" width="5" height="5" rx="1.5"></rect>
14
+ <rect fill="#8B8FA3" x="21" y="0" width="5" height="5" rx="1.5"></rect>
15
+ <rect fill="#8B8FA3" x="21" y="6" width="5" height="5" rx="1.5"></rect>
16
+ </g>
17
+ <path d="M3,3 L33,3 C34.6568542,3 36,4.34314575 36,6 L36,12 L36,12 L0,12 L0,6 C-2.02906125e-16,4.34314575 1.34314575,3 3,3 Z" fill="#D7D9E0"></path>
18
+ <rect fill="#D7D9E0" x="7" y="0" width="4" height="8" rx="1"></rect>
19
+ <rect fill="#D7D9E0" x="25" y="0" width="4" height="8" rx="1"></rect>
20
+ </g>
21
+ </g>
22
+ </svg>
@@ -0,0 +1,5 @@
1
+ import { aJ as f } from "./2b3ab1e4.js";
2
+ export {
3
+ f as default
4
+ };
5
+ (function(){"use strict";try{if(typeof document!="undefined"){var e=document.createElement("style");e.id="lowcoder-comps-0.0.8",e.appendChild(document.createTextNode("")),document.head.appendChild(e)}}catch(c){console.error("vite-plugin-css-injected-by-js",c)}})();
@@ -0,0 +1,73 @@
1
+ {
2
+ "name": "lowcoder-comps",
3
+ "version": "0.0.8",
4
+ "type": "module",
5
+ "license": "MIT",
6
+ "dependencies": {
7
+ "@fullcalendar/core": "^6.1.6",
8
+ "@fullcalendar/daygrid": "^6.1.6",
9
+ "@fullcalendar/interaction": "^6.1.6",
10
+ "@fullcalendar/list": "^6.1.6",
11
+ "@fullcalendar/moment": "^6.1.6",
12
+ "@fullcalendar/react": "^6.1.6",
13
+ "@fullcalendar/timegrid": "^6.1.6",
14
+ "@types/react": "17",
15
+ "@types/react-dom": "17",
16
+ "big.js": "^6.2.1",
17
+ "lowcoder-cli": "workspace:^",
18
+ "lowcoder-sdk": "workspace:^",
19
+ "mermaid": "^10.1.x0",
20
+ "react": "17",
21
+ "react-dom": "17",
22
+ "typescript": "4.8.4"
23
+ },
24
+ "lowcoder": {
25
+ "description": "",
26
+ "comps": {
27
+ "chart": {
28
+ "name": "Chart",
29
+ "icon": "./icons/icon-chart.svg",
30
+ "layoutInfo": {
31
+ "w": 11,
32
+ "h": 35
33
+ }
34
+ },
35
+ "imageEditor": {
36
+ "name": "Image Editor",
37
+ "icon": "./icons/icon-chart.svg",
38
+ "layoutInfo": {
39
+ "w": 15,
40
+ "h": 60
41
+ }
42
+ },
43
+ "calendar": {
44
+ "name": "Calendar",
45
+ "icon": "./icons/icon-comp-calendar.svg",
46
+ "layoutInfo": {
47
+ "w": 15,
48
+ "h": 60
49
+ }
50
+ },
51
+ "mermaid": {
52
+ "name": "Mermaid",
53
+ "icon": "./icons/icon-chart.svg",
54
+ "layoutInfo": {
55
+ "w": 15,
56
+ "h": 60
57
+ }
58
+ }
59
+ },
60
+ "entry": "index.js"
61
+ },
62
+ "scripts": {
63
+ "start": "vite",
64
+ "build": "yarn test && lowcoder-cli build",
65
+ "build_only": "lowcoder-cli build",
66
+ "test": "jest"
67
+ },
68
+ "devDependencies": {
69
+ "jest": "29.3.0",
70
+ "vite": "^3.2.4",
71
+ "vite-tsconfig-paths": "^3.6.0"
72
+ }
73
+ }
package/package.json CHANGED
@@ -1,11 +1,8 @@
1
1
  {
2
2
  "name": "lowcoder-comps",
3
- "version": "0.0.7",
3
+ "version": "0.0.8",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
- "files": [
7
- "tsconfig.json"
8
- ],
9
6
  "dependencies": {
10
7
  "@fullcalendar/core": "^6.1.6",
11
8
  "@fullcalendar/daygrid": "^6.1.6",
@@ -0,0 +1,61 @@
1
+ import _ from "lodash";
2
+ import { CompConstructor, CustomAction } from "lowcoder-core";
3
+ import { evalAndReduce, isExposingMethodComp } from "lowcoder-sdk";
4
+ import { ChartCompWithDefault } from "comps/chartComp/chartComp";
5
+ import log from "loglevel";
6
+
7
+ const COMPS_MAP = {
8
+ chart: ChartCompWithDefault,
9
+ } as Record<string, CompConstructor>;
10
+
11
+ const compContextActionMap = {} as Record<string, CustomAction>;
12
+
13
+ test("test comp don't change if no value change", () => {
14
+ Object.keys(COMPS_MAP).forEach((name) => {
15
+ const Comp = COMPS_MAP[name];
16
+ let comp = new Comp({});
17
+ if (compContextActionMap[name]) {
18
+ // set context
19
+ comp = comp.reduce(compContextActionMap[name]);
20
+ }
21
+ comp.getView(); // getView() is allowed when unevaluated
22
+ comp = evalAndReduce(comp);
23
+ expect(comp.node() === comp.node()).toBe(true);
24
+ expect(comp.node()?.evaluate() === comp.node()?.evaluate()).toBe(true);
25
+ const comp2 = evalAndReduce(comp);
26
+ if (comp2 !== comp) {
27
+ const comp3 = evalAndReduce(comp2);
28
+ if (comp3 === comp2) {
29
+ // log.debug(`${name} need eval twice to converge`);
30
+ } else {
31
+ const newComp = evalAndReduce(comp);
32
+ Object.keys((comp as any).children).forEach((key) => {
33
+ log.log(
34
+ `${key}, isEqual ${(comp as any).children[key] === (newComp as any).children[key]}`
35
+ );
36
+ });
37
+ throw new Error("bad " + name);
38
+ }
39
+ }
40
+ });
41
+ });
42
+
43
+ test("comp exposing method duplicate name", () => {
44
+ // one comp can't expose two methods with the same name
45
+ Object.values(COMPS_MAP).forEach((Comp) => {
46
+ const comp = new Comp({});
47
+ const methods = [];
48
+ if (isExposingMethodComp(comp)) {
49
+ methods.push(comp.getMethodConfig());
50
+ }
51
+ const childrenMap = (comp as any).children;
52
+ childrenMap &&
53
+ Object.values(childrenMap).forEach((child) => {
54
+ if (isExposingMethodComp(child as any)) {
55
+ methods.push((child as any).getMethodConfig());
56
+ }
57
+ });
58
+ const allMethodName = methods.flatMap((m) => m.map((methodConfig) => methodConfig.name));
59
+ expect(allMethodName.length).toEqual(_.uniq(allMethodName).length);
60
+ });
61
+ });
@@ -0,0 +1,3 @@
1
+ /// <reference types="lowcoder-cli/client" />
2
+
3
+ declare module "lowcoder-sdk";
@@ -0,0 +1,442 @@
1
+ import {
2
+ isValidColor,
3
+ NameConfig,
4
+ NameConfigHidden,
5
+ BoolControl,
6
+ UICompBuilder,
7
+ withDefault,
8
+ withExposingConfigs,
9
+ NumberControl,
10
+ StringControl,
11
+ hiddenPropertyView,
12
+ ChangeEventHandlerControl,
13
+ Section,
14
+ sectionNames,
15
+ dropdownControl,
16
+ styleControl,
17
+ ThemeContext,
18
+ CalendarStyle,
19
+ DateParser,
20
+ CustomModal,
21
+ jsonValueExposingStateControl,
22
+ CalendarDeleteIcon,
23
+ Tooltip,
24
+ } from "lowcoder-sdk";
25
+ import { Input, Form } from "antd";
26
+ import { trans, getCalendarLocale } from "../../i18n/comps";
27
+ import { createRef, useContext, useRef, useState } from "react";
28
+ import FullCalendar from "@fullcalendar/react";
29
+ import dayGridPlugin from "@fullcalendar/daygrid";
30
+ import timeGridPlugin from "@fullcalendar/timegrid";
31
+ import interactionPlugin from "@fullcalendar/interaction";
32
+ import listPlugin from "@fullcalendar/list";
33
+ import allLocales from "@fullcalendar/core/locales-all";
34
+ import { EventContentArg, DateSelectArg } from "@fullcalendar/core";
35
+ import momentPlugin from "@fullcalendar/moment";
36
+ import {
37
+ DefaultViewOptions,
38
+ FirstDayOptions,
39
+ Wrapper,
40
+ Event,
41
+ Remove,
42
+ EventType,
43
+ defaultData,
44
+ ViewType,
45
+ buttonText,
46
+ headerToolbar,
47
+ views,
48
+ slotLabelFormat,
49
+ viewClassNames,
50
+ FormWrapper,
51
+ } from "./calendarConstants";
52
+ import moment from "moment";
53
+
54
+ const childrenMap = {
55
+ events: jsonValueExposingStateControl("events", defaultData),
56
+ onEvent: ChangeEventHandlerControl,
57
+
58
+ editable: withDefault(BoolControl, true),
59
+ defaultDate: withDefault(StringControl, "{{ new Date() }}"),
60
+ defaultView: dropdownControl(DefaultViewOptions, "timeGridWeek"),
61
+ firstDay: dropdownControl(FirstDayOptions, "1"),
62
+ showEventTime: withDefault(BoolControl, true),
63
+ showWeekends: withDefault(BoolControl, true),
64
+ showAllDay: withDefault(BoolControl, true),
65
+ dayMaxEvents: withDefault(NumberControl, 2),
66
+ eventMaxStack: withDefault(NumberControl, 0),
67
+ style: styleControl(CalendarStyle),
68
+ };
69
+
70
+ let CalendarBasicComp = (function () {
71
+ return new UICompBuilder(childrenMap, (props) => {
72
+ const theme = useContext(ThemeContext);
73
+ const ref = createRef<HTMLDivElement>();
74
+ const editEvent = useRef<EventType>();
75
+ const [form] = Form.useForm();
76
+ const [left, setLeft] = useState<number | undefined>(undefined);
77
+
78
+ const events = props.events.value.map((item: EventType) => {
79
+ return {
80
+ title: item.title,
81
+ id: item.id,
82
+ start: moment(item.start, DateParser).format(),
83
+ end: moment(item.end, DateParser).format(),
84
+ allDay: item.allDay,
85
+ color: isValidColor(item.color || "") ? item.color : theme?.theme?.primary,
86
+ ...(item.groupId ? { groupId: item.groupId } : null),
87
+ };
88
+ });
89
+
90
+ const {
91
+ defaultDate,
92
+ defaultView,
93
+ showEventTime,
94
+ showWeekends,
95
+ showAllDay,
96
+ dayMaxEvents,
97
+ eventMaxStack,
98
+ style,
99
+ firstDay,
100
+ editable,
101
+ } = props;
102
+
103
+ function renderEventContent(eventInfo: EventContentArg) {
104
+ const isList = eventInfo.view.type === "listWeek";
105
+ let sizeClass = "";
106
+ if ([ViewType.WEEK, ViewType.DAY].includes(eventInfo.view.type as ViewType)) {
107
+ const duration = moment(eventInfo.event.end).diff(moment(eventInfo.event.start), "minutes");
108
+ if (duration <= 30 || eventInfo.event.allDay) {
109
+ sizeClass = "small";
110
+ } else if (duration <= 60) {
111
+ sizeClass = "middle";
112
+ } else {
113
+ sizeClass = "large";
114
+ }
115
+ }
116
+ const stateClass =
117
+ moment().isAfter(moment(eventInfo.event.end)) &&
118
+ (eventInfo.view.type as ViewType) !== ViewType.MONTH
119
+ ? "past"
120
+ : "";
121
+
122
+ return (
123
+ <Event
124
+ className={`event ${sizeClass} ${stateClass}`}
125
+ isList={isList}
126
+ bg={eventInfo.backgroundColor}
127
+ theme={theme?.theme}
128
+ $style={props.style}
129
+ >
130
+ <div className="event-time">{eventInfo.timeText}</div>
131
+ <div className="event-title">{eventInfo.event.title}</div>
132
+ <Remove
133
+ isList={isList}
134
+ className="event-remove"
135
+ onClick={(e) => {
136
+ e.stopPropagation();
137
+ props.onEvent("change");
138
+ const event = events.filter((item: EventType) => item.id !== eventInfo.event.id);
139
+ props.events.onChange(event);
140
+ }}
141
+ onMouseDown={(e) => {
142
+ e.stopPropagation();
143
+ e.preventDefault();
144
+ }}
145
+ >
146
+ <CalendarDeleteIcon />
147
+ </Remove>
148
+ </Event>
149
+ );
150
+ }
151
+
152
+ const handleDbClick = () => {
153
+ const event = props.events.value.find(
154
+ (item: EventType) => item.id === editEvent.current?.id
155
+ ) as EventType;
156
+ if (!editable || !editEvent.current) {
157
+ return;
158
+ }
159
+ if (event) {
160
+ const { title, groupId, color, id } = event;
161
+ const eventInfo = {
162
+ title,
163
+ groupId,
164
+ color,
165
+ id,
166
+ };
167
+ showModal(eventInfo, true);
168
+ } else {
169
+ showModal(editEvent.current, false);
170
+ }
171
+ };
172
+
173
+ const handleCreate = (info: DateSelectArg) => {
174
+ const event = {
175
+ allDay: info.allDay,
176
+ start: info.startStr,
177
+ end: info.endStr,
178
+ };
179
+ const view = info.view.type as ViewType;
180
+ const duration = moment(info.end).diff(moment(info.start), "minutes");
181
+ const singleClick =
182
+ (view === ViewType.MONTH && duration === 1440) ||
183
+ ([ViewType.WEEK, ViewType.DAY].includes(view) && duration === 30) ||
184
+ (info.allDay && duration === 1440);
185
+ if (singleClick) {
186
+ editEvent.current = event;
187
+ setTimeout(() => {
188
+ editEvent.current = undefined;
189
+ }, 500);
190
+ return;
191
+ }
192
+ showModal(event, false);
193
+ };
194
+
195
+ const showModal = (event: EventType, ifEdit: boolean) => {
196
+ const modalTitle = ifEdit ? trans("calendar.editEvent") : trans("calendar.creatEvent");
197
+ form && form.setFieldsValue(event);
198
+ const eventId = editEvent.current?.id;
199
+ CustomModal.confirm({
200
+ title: modalTitle,
201
+ content: (
202
+ <FormWrapper form={form}>
203
+ <Form.Item
204
+ label={
205
+ <Tooltip title={trans("calendar.eventIdTooltip")}>
206
+ {trans("calendar.eventId")}
207
+ </Tooltip>
208
+ }
209
+ name="id"
210
+ rules={[{ required: true, message: trans("calendar.eventIdRequire") }]}
211
+ >
212
+ <Input />
213
+ </Form.Item>
214
+ <Form.Item
215
+ label={trans("calendar.eventName")}
216
+ name="title"
217
+ rules={[{ required: true, message: trans("calendar.eventNameRequire") }]}
218
+ >
219
+ <Input />
220
+ </Form.Item>
221
+ <Form.Item label={trans("calendar.eventColor")} name="color">
222
+ <Input />
223
+ </Form.Item>
224
+ <Form.Item
225
+ label={
226
+ <Tooltip title={trans("calendar.groupIdTooltip")}>
227
+ {trans("calendar.eventGroupId")}
228
+ </Tooltip>
229
+ }
230
+ name="groupId"
231
+ >
232
+ <Input />
233
+ </Form.Item>
234
+ </FormWrapper>
235
+ ),
236
+ onConfirm: () => {
237
+ form.submit();
238
+ return form.validateFields().then(() => {
239
+ const { id, groupId, color, title = "" } = form.getFieldsValue();
240
+ const idExist = props.events.value.findIndex((item: EventType) => item.id === id);
241
+ if (idExist > -1 && id !== eventId) {
242
+ form.setFields([{ name: "id", errors: [trans("calendar.eventIdExist")] }]);
243
+ throw new Error();
244
+ }
245
+ if (ifEdit) {
246
+ const changeEvents = props.events.value.map((item: EventType) => {
247
+ if (item.id === eventId) {
248
+ return {
249
+ ...item,
250
+ title,
251
+ id,
252
+ ...(groupId !== undefined ? { groupId } : null),
253
+ ...(color !== undefined ? { color } : null),
254
+ };
255
+ } else {
256
+ return item;
257
+ }
258
+ });
259
+ props.events.onChange(changeEvents);
260
+ } else {
261
+ const createInfo = {
262
+ allDay: event.allDay,
263
+ start: event.start,
264
+ end: event.end,
265
+ id,
266
+ title,
267
+ ...(groupId !== undefined ? { groupId } : null),
268
+ ...(color !== undefined ? { color } : null),
269
+ };
270
+ props.events.onChange([...props.events.value, createInfo]);
271
+ }
272
+ props.onEvent("change");
273
+ form.resetFields();
274
+ });
275
+ },
276
+ onCancel: () => {
277
+ form.resetFields();
278
+ },
279
+ });
280
+ };
281
+
282
+ let initialDate = defaultDate;
283
+ try {
284
+ initialDate = new Date(defaultDate).toISOString();
285
+ } catch (error) {
286
+ initialDate = undefined;
287
+ }
288
+
289
+ return (
290
+ <Wrapper
291
+ ref={ref}
292
+ editable={editable}
293
+ $style={style}
294
+ theme={theme?.theme}
295
+ onDoubleClick={handleDbClick}
296
+ left={left}
297
+ key={initialDate ? defaultView + initialDate : defaultView}
298
+ >
299
+ <FullCalendar
300
+ slotEventOverlap={false}
301
+ events={events}
302
+ expandRows={true}
303
+ height={"100%"}
304
+ locale={getCalendarLocale()}
305
+ locales={allLocales}
306
+ firstDay={Number(firstDay)}
307
+ plugins={[dayGridPlugin, timeGridPlugin, interactionPlugin, listPlugin, momentPlugin]}
308
+ headerToolbar={headerToolbar}
309
+ moreLinkClick={(info) => {
310
+ let left = 0;
311
+ const ele = info.jsEvent.target as HTMLElement;
312
+ if (info.view.type === ViewType.DAY) {
313
+ if (info.allDay) {
314
+ left = ele.offsetParent?.parentElement?.offsetLeft || 0;
315
+ } else {
316
+ left = ele.parentElement?.offsetLeft || 0;
317
+ }
318
+ } else {
319
+ if (info.allDay) {
320
+ left = ele.offsetParent?.parentElement?.parentElement?.offsetLeft || 0;
321
+ } else {
322
+ left =
323
+ ele.offsetParent?.parentElement?.parentElement?.parentElement?.offsetLeft || 0;
324
+ }
325
+ }
326
+ setLeft(left);
327
+ }}
328
+ buttonText={buttonText}
329
+ views={views}
330
+ eventClassNames={() => (!showEventTime ? "no-time" : "")}
331
+ slotLabelFormat={slotLabelFormat}
332
+ viewClassNames={viewClassNames}
333
+ moreLinkText={trans("calendar.more")}
334
+ initialDate={initialDate}
335
+ initialView={defaultView}
336
+ editable={editable}
337
+ selectable={editable}
338
+ selectMirror={false}
339
+ displayEventTime={showEventTime}
340
+ dayMaxEvents={dayMaxEvents}
341
+ eventMaxStack={eventMaxStack || undefined}
342
+ weekends={showWeekends}
343
+ allDaySlot={showAllDay}
344
+ eventContent={renderEventContent}
345
+ select={(info) => handleCreate(info)}
346
+ eventClick={(info) => {
347
+ const event = events.find((item: EventType) => item.id === info.event.id);
348
+ editEvent.current = event;
349
+ setTimeout(() => {
350
+ editEvent.current = undefined;
351
+ }, 500);
352
+ }}
353
+ eventsSet={(info) => {
354
+ let needChange = false;
355
+ let changeEvents: EventType[] = [];
356
+ info.forEach((item) => {
357
+ const event = events.find((i: EventType) => i.id === item.id);
358
+ const start = moment(item.start, DateParser).format();
359
+ const end = moment(item.end, DateParser).format();
360
+ if (
361
+ start !== event?.start ||
362
+ end !== event?.end ||
363
+ !!item.allDay !== !!event?.allDay
364
+ ) {
365
+ needChange = true;
366
+ changeEvents.push({
367
+ ...event,
368
+ allDay: item.allDay,
369
+ start: item.startStr,
370
+ end: item.endStr,
371
+ });
372
+ } else {
373
+ changeEvents.push(event);
374
+ }
375
+ });
376
+ if (needChange) {
377
+ props.events.onChange(changeEvents);
378
+ props.onEvent("change");
379
+ }
380
+ }}
381
+ />
382
+ </Wrapper>
383
+ );
384
+ })
385
+ .setPropertyViewFn((children) => {
386
+ return (
387
+ <>
388
+ <Section name={sectionNames.basic}>{children.events.propertyView({})}</Section>
389
+ <Section name={sectionNames.interaction}>{children.onEvent.getPropertyView()}</Section>
390
+ <Section name={sectionNames.advanced}>
391
+ {children.editable.propertyView({
392
+ label: trans("calendar.editable"),
393
+ })}
394
+ {children.defaultDate.propertyView({
395
+ label: trans("calendar.defaultDate"),
396
+ tooltip: trans("calendar.defaultDateTooltip"),
397
+ })}
398
+ {children.defaultView.propertyView({
399
+ label: trans("calendar.defaultView"),
400
+ tooltip: trans("calendar.defaultViewTooltip"),
401
+ })}
402
+ {children.firstDay.propertyView({
403
+ label: trans("calendar.startWeek"),
404
+ })}
405
+ {children.showEventTime.propertyView({
406
+ label: trans("calendar.showEventTime"),
407
+ tooltip: trans("calendar.showEventTimeTooltip"),
408
+ })}
409
+ {children.showWeekends.propertyView({
410
+ label: trans("calendar.showWeekends"),
411
+ })}
412
+ {children.showAllDay.propertyView({
413
+ label: trans("calendar.showAllDay"),
414
+ tooltip: trans("calendar.showAllDayTooltip"),
415
+ })}
416
+ {children.dayMaxEvents.propertyView({
417
+ label: trans("calendar.dayMaxEvents"),
418
+ tooltip: trans("calendar.dayMaxEventsTooltip"),
419
+ })}
420
+ {children.eventMaxStack.propertyView({
421
+ label: trans("calendar.eventMaxStack"),
422
+ tooltip: trans("calendar.eventMaxStackTooltip"),
423
+ })}
424
+ </Section>
425
+ <Section name={sectionNames.layout}>{hiddenPropertyView(children)}</Section>
426
+ <Section name={sectionNames.style}>{children.style.getPropertyView()}</Section>
427
+ </>
428
+ );
429
+ })
430
+ .build();
431
+ })();
432
+
433
+ CalendarBasicComp = class extends CalendarBasicComp {
434
+ override autoHeight(): boolean {
435
+ return false;
436
+ }
437
+ };
438
+
439
+ export const CalendarComp = withExposingConfigs(CalendarBasicComp, [
440
+ new NameConfig("events", trans("calendar.events")),
441
+ NameConfigHidden,
442
+ ]);