lowcoder-comps 0.0.10 → 0.0.11
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/index.js +91356 -0
- package/package.json +4 -3
- package/README.md +0 -27
- package/index.html +0 -26
- package/index.tsx +0 -19
- package/jest.config.js +0 -5
- package/src/__test__/allComp.test.tsx +0 -61
- package/src/app-env.d.ts +0 -3
- package/src/comps/calendarComp/calendarComp.tsx +0 -442
- package/src/comps/calendarComp/calendarConstants.tsx +0 -897
- package/src/comps/chartComp/chartComp.tsx +0 -249
- 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 -6
- 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 -243
- package/src/comps/chartComp/chartPropertyView.tsx +0 -161
- package/src/comps/chartComp/chartUtils.ts +0 -240
- package/src/comps/chartComp/reactEcharts/core.tsx +0 -187
- package/src/comps/chartComp/reactEcharts/index.ts +0 -20
- package/src/comps/chartComp/reactEcharts/types.ts +0 -70
- 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 -142
- package/src/i18n/comps/locales/enObj.tsx +0 -120
- package/src/i18n/comps/locales/index.ts +0 -7
- package/src/i18n/comps/locales/types.tsx +0 -9
- package/src/i18n/comps/locales/zh.ts +0 -4
- package/src/i18n/comps/locales/zhObj.tsx +0 -4
- package/src/index.ts +0 -9
- package/tsconfig.json +0 -22
- package/vite.config.js +0 -10
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lowcoder-comps",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.11",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"dependencies": {
|
|
@@ -48,7 +48,8 @@
|
|
|
48
48
|
"h": 60
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
-
}
|
|
51
|
+
},
|
|
52
|
+
"entry": "index.js"
|
|
52
53
|
},
|
|
53
54
|
"scripts": {
|
|
54
55
|
"start": "vite",
|
|
@@ -61,4 +62,4 @@
|
|
|
61
62
|
"vite": "^3.2.4",
|
|
62
63
|
"vite-tsconfig-paths": "^3.6.0"
|
|
63
64
|
}
|
|
64
|
-
}
|
|
65
|
+
}
|
package/README.md
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
# lowcoder comp lib
|
|
2
|
-
|
|
3
|
-
## Start
|
|
4
|
-
|
|
5
|
-
Start dev server to develop your comp lib.
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
yarn start
|
|
9
|
-
|
|
10
|
-
# or
|
|
11
|
-
|
|
12
|
-
npm start
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
## Build
|
|
16
|
-
|
|
17
|
-
Build current comp lib into a .tgz file that you can upload it to the Lowcoder Comp Market.
|
|
18
|
-
|
|
19
|
-
Before build you should change the version in package.json file.
|
|
20
|
-
|
|
21
|
-
```bash
|
|
22
|
-
yarn build
|
|
23
|
-
|
|
24
|
-
# or
|
|
25
|
-
|
|
26
|
-
npm run build
|
|
27
|
-
```
|
package/index.html
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8" />
|
|
5
|
-
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
|
6
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
-
<title>Lowcoder Comp Playground</title>
|
|
8
|
-
<style>
|
|
9
|
-
#root {
|
|
10
|
-
height: 100vh;
|
|
11
|
-
}
|
|
12
|
-
#root-loader {
|
|
13
|
-
height: 100vh;
|
|
14
|
-
display: flex;
|
|
15
|
-
justify-content: center;
|
|
16
|
-
align-items: center;
|
|
17
|
-
}
|
|
18
|
-
</style>
|
|
19
|
-
</head>
|
|
20
|
-
<body>
|
|
21
|
-
<div id="root">
|
|
22
|
-
<div id="root-loader">Loading...</div>
|
|
23
|
-
</div>
|
|
24
|
-
<script src="index.tsx" type="module"></script>
|
|
25
|
-
</body>
|
|
26
|
-
</html>
|
package/index.tsx
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import ReactDOM from "react-dom";
|
|
2
|
-
import { CompIDE } from "lowcoder-sdk";
|
|
3
|
-
import { name, version, lowcoder } from "./package.json";
|
|
4
|
-
import compMap from "./src/index";
|
|
5
|
-
|
|
6
|
-
import "lowcoder-sdk/dist/style.css";
|
|
7
|
-
|
|
8
|
-
function CompDevApp() {
|
|
9
|
-
return (
|
|
10
|
-
<CompIDE
|
|
11
|
-
compMap={compMap}
|
|
12
|
-
packageName={name}
|
|
13
|
-
packageVersion={version}
|
|
14
|
-
compMeta={lowcoder.comps}
|
|
15
|
-
/>
|
|
16
|
-
);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
ReactDOM.render(<CompDevApp />, document.querySelector("#root"));
|
package/jest.config.js
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
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
|
-
});
|
package/src/app-env.d.ts
DELETED
|
@@ -1,442 +0,0 @@
|
|
|
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
|
-
]);
|