lowcoder-comps 0.0.19 → 0.0.20
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/01102044.js +940 -0
- package/011ccb4a.js +46688 -0
- package/0d5d7030.js +212 -0
- package/0e8dfd52.js +793 -0
- package/0f25771b.js +1118 -0
- package/2470e1d8.js +91 -0
- package/256b619e.js +92 -0
- package/2ff2c7a6.js +6 -0
- package/3196b84f.js +798 -0
- package/31c6e136.js +34 -0
- package/32432dc3.js +86 -0
- package/36552e14.js +849 -0
- package/384b70d4.js +24 -0
- package/3ad35722.js +365 -0
- package/3f4db197.js +943 -0
- package/4791bdd6.js +117321 -0
- package/5a7c40d7.js +18619 -0
- package/5fd0f607.js +447 -0
- package/71827e37.js +1032 -0
- package/7a200c6a.js +607 -0
- package/804e952b.js +451 -0
- package/872f2918.js +7 -0
- package/8d714103.js +1602 -0
- package/93b98f3e.js +832 -0
- package/a06ced05.js +326 -0
- package/a1f987b7.js +236 -0
- package/a42a2ba9.js +2103 -0
- package/af0489f3.js +2456 -0
- package/b56f953d.js +985 -0
- package/b89c6a6a.js +159 -0
- package/bc7030d3.js +70 -0
- package/c739ba3e.js +2679 -0
- package/d306d59c.js +2827 -0
- package/d8adcd1e.js +823 -0
- package/e1466a22.js +275 -0
- package/ef845d7f.js +1246 -0
- package/f9637058.js +16 -0
- package/index.js +5 -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 -6
- package/src/__test__/allComp.test.tsx +0 -61
- package/src/app-env.d.ts +0 -3
- package/src/comps/calendarComp/calendarComp.tsx +0 -443
- package/src/comps/calendarComp/calendarConstants.tsx +0 -898
- package/src/comps/chartComp/chartComp.tsx +0 -356
- 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 -288
- package/src/comps/chartComp/chartPropertyView.tsx +0 -218
- 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 -150
- 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 -145
- 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
package/f9637058.js
ADDED
package/index.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
(function(){"use strict";try{if(typeof document!="undefined"){var e=document.createElement("style");e.id="lowcoder-comps-0.0.20",e.appendChild(document.createTextNode("")),document.head.appendChild(e)}}catch(c){console.error("vite-plugin-css-injected-by-js",c)}})();
|
|
2
|
+
import { aO as f } from "./4791bdd6.js";
|
|
3
|
+
export {
|
|
4
|
+
f as default
|
|
5
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lowcoder-comps",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.20",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"dependencies": {
|
|
@@ -58,7 +58,8 @@
|
|
|
58
58
|
"h": 40
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
-
}
|
|
61
|
+
},
|
|
62
|
+
"entry": "index.js"
|
|
62
63
|
},
|
|
63
64
|
"scripts": {
|
|
64
65
|
"start": "vite",
|
|
@@ -73,4 +74,4 @@
|
|
|
73
74
|
"vite": "^4.3.9",
|
|
74
75
|
"vite-tsconfig-paths": "^3.6.0"
|
|
75
76
|
}
|
|
76
|
-
}
|
|
77
|
+
}
|
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,443 +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 dayjs from "dayjs";
|
|
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: dayjs(item.start, DateParser).format(),
|
|
83
|
-
end: dayjs(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 = dayjs(eventInfo.event.end).diff(dayjs(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
|
-
dayjs().isAfter(dayjs(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
|
-
allDay={showAllDay}
|
|
129
|
-
$style={props.style}
|
|
130
|
-
>
|
|
131
|
-
<div className="event-time">{eventInfo.timeText}</div>
|
|
132
|
-
<div className="event-title">{eventInfo.event.title}</div>
|
|
133
|
-
<Remove
|
|
134
|
-
isList={isList}
|
|
135
|
-
className="event-remove"
|
|
136
|
-
onClick={(e) => {
|
|
137
|
-
e.stopPropagation();
|
|
138
|
-
props.onEvent("change");
|
|
139
|
-
const event = events.filter((item: EventType) => item.id !== eventInfo.event.id);
|
|
140
|
-
props.events.onChange(event);
|
|
141
|
-
}}
|
|
142
|
-
onMouseDown={(e) => {
|
|
143
|
-
e.stopPropagation();
|
|
144
|
-
e.preventDefault();
|
|
145
|
-
}}
|
|
146
|
-
>
|
|
147
|
-
<CalendarDeleteIcon />
|
|
148
|
-
</Remove>
|
|
149
|
-
</Event>
|
|
150
|
-
);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
const handleDbClick = () => {
|
|
154
|
-
const event = props.events.value.find(
|
|
155
|
-
(item: EventType) => item.id === editEvent.current?.id
|
|
156
|
-
) as EventType;
|
|
157
|
-
if (!editable || !editEvent.current) {
|
|
158
|
-
return;
|
|
159
|
-
}
|
|
160
|
-
if (event) {
|
|
161
|
-
const { title, groupId, color, id } = event;
|
|
162
|
-
const eventInfo = {
|
|
163
|
-
title,
|
|
164
|
-
groupId,
|
|
165
|
-
color,
|
|
166
|
-
id,
|
|
167
|
-
};
|
|
168
|
-
showModal(eventInfo, true);
|
|
169
|
-
} else {
|
|
170
|
-
showModal(editEvent.current, false);
|
|
171
|
-
}
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
const handleCreate = (info: DateSelectArg) => {
|
|
175
|
-
const event = {
|
|
176
|
-
allDay: info.allDay,
|
|
177
|
-
start: info.startStr,
|
|
178
|
-
end: info.endStr,
|
|
179
|
-
};
|
|
180
|
-
const view = info.view.type as ViewType;
|
|
181
|
-
const duration = dayjs(info.end).diff(dayjs(info.start), "minutes");
|
|
182
|
-
const singleClick =
|
|
183
|
-
(view === ViewType.MONTH && duration === 1440) ||
|
|
184
|
-
([ViewType.WEEK, ViewType.DAY].includes(view) && duration === 30) ||
|
|
185
|
-
(info.allDay && duration === 1440);
|
|
186
|
-
if (singleClick) {
|
|
187
|
-
editEvent.current = event;
|
|
188
|
-
setTimeout(() => {
|
|
189
|
-
editEvent.current = undefined;
|
|
190
|
-
}, 500);
|
|
191
|
-
return;
|
|
192
|
-
}
|
|
193
|
-
showModal(event, false);
|
|
194
|
-
};
|
|
195
|
-
|
|
196
|
-
const showModal = (event: EventType, ifEdit: boolean) => {
|
|
197
|
-
const modalTitle = ifEdit ? trans("calendar.editEvent") : trans("calendar.creatEvent");
|
|
198
|
-
form && form.setFieldsValue(event);
|
|
199
|
-
const eventId = editEvent.current?.id;
|
|
200
|
-
CustomModal.confirm({
|
|
201
|
-
title: modalTitle,
|
|
202
|
-
content: (
|
|
203
|
-
<FormWrapper form={form}>
|
|
204
|
-
<Form.Item
|
|
205
|
-
label={
|
|
206
|
-
<Tooltip title={trans("calendar.eventIdTooltip")}>
|
|
207
|
-
{trans("calendar.eventId")}
|
|
208
|
-
</Tooltip>
|
|
209
|
-
}
|
|
210
|
-
name="id"
|
|
211
|
-
rules={[{ required: true, message: trans("calendar.eventIdRequire") }]}
|
|
212
|
-
>
|
|
213
|
-
<Input />
|
|
214
|
-
</Form.Item>
|
|
215
|
-
<Form.Item
|
|
216
|
-
label={trans("calendar.eventName")}
|
|
217
|
-
name="title"
|
|
218
|
-
rules={[{ required: true, message: trans("calendar.eventNameRequire") }]}
|
|
219
|
-
>
|
|
220
|
-
<Input />
|
|
221
|
-
</Form.Item>
|
|
222
|
-
<Form.Item label={trans("calendar.eventColor")} name="color">
|
|
223
|
-
<Input />
|
|
224
|
-
</Form.Item>
|
|
225
|
-
<Form.Item
|
|
226
|
-
label={
|
|
227
|
-
<Tooltip title={trans("calendar.groupIdTooltip")}>
|
|
228
|
-
{trans("calendar.eventGroupId")}
|
|
229
|
-
</Tooltip>
|
|
230
|
-
}
|
|
231
|
-
name="groupId"
|
|
232
|
-
>
|
|
233
|
-
<Input />
|
|
234
|
-
</Form.Item>
|
|
235
|
-
</FormWrapper>
|
|
236
|
-
),
|
|
237
|
-
onConfirm: () => {
|
|
238
|
-
form.submit();
|
|
239
|
-
return form.validateFields().then(() => {
|
|
240
|
-
const { id, groupId, color, title = "" } = form.getFieldsValue();
|
|
241
|
-
const idExist = props.events.value.findIndex((item: EventType) => item.id === id);
|
|
242
|
-
if (idExist > -1 && id !== eventId) {
|
|
243
|
-
form.setFields([{ name: "id", errors: [trans("calendar.eventIdExist")] }]);
|
|
244
|
-
throw new Error();
|
|
245
|
-
}
|
|
246
|
-
if (ifEdit) {
|
|
247
|
-
const changeEvents = props.events.value.map((item: EventType) => {
|
|
248
|
-
if (item.id === eventId) {
|
|
249
|
-
return {
|
|
250
|
-
...item,
|
|
251
|
-
title,
|
|
252
|
-
id,
|
|
253
|
-
...(groupId !== undefined ? { groupId } : null),
|
|
254
|
-
...(color !== undefined ? { color } : null),
|
|
255
|
-
};
|
|
256
|
-
} else {
|
|
257
|
-
return item;
|
|
258
|
-
}
|
|
259
|
-
});
|
|
260
|
-
props.events.onChange(changeEvents);
|
|
261
|
-
} else {
|
|
262
|
-
const createInfo = {
|
|
263
|
-
allDay: event.allDay,
|
|
264
|
-
start: event.start,
|
|
265
|
-
end: event.end,
|
|
266
|
-
id,
|
|
267
|
-
title,
|
|
268
|
-
...(groupId !== undefined ? { groupId } : null),
|
|
269
|
-
...(color !== undefined ? { color } : null),
|
|
270
|
-
};
|
|
271
|
-
props.events.onChange([...props.events.value, createInfo]);
|
|
272
|
-
}
|
|
273
|
-
props.onEvent("change");
|
|
274
|
-
form.resetFields();
|
|
275
|
-
});
|
|
276
|
-
},
|
|
277
|
-
onCancel: () => {
|
|
278
|
-
form.resetFields();
|
|
279
|
-
},
|
|
280
|
-
});
|
|
281
|
-
};
|
|
282
|
-
|
|
283
|
-
let initialDate = defaultDate;
|
|
284
|
-
try {
|
|
285
|
-
initialDate = new Date(defaultDate).toISOString();
|
|
286
|
-
} catch (error) {
|
|
287
|
-
initialDate = undefined;
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
return (
|
|
291
|
-
<Wrapper
|
|
292
|
-
ref={ref}
|
|
293
|
-
editable={editable}
|
|
294
|
-
$style={style}
|
|
295
|
-
theme={theme?.theme}
|
|
296
|
-
onDoubleClick={handleDbClick}
|
|
297
|
-
left={left}
|
|
298
|
-
key={initialDate ? defaultView + initialDate : defaultView}
|
|
299
|
-
>
|
|
300
|
-
<FullCalendar
|
|
301
|
-
slotEventOverlap={false}
|
|
302
|
-
events={events}
|
|
303
|
-
expandRows={true}
|
|
304
|
-
height={"100%"}
|
|
305
|
-
locale={getCalendarLocale()}
|
|
306
|
-
locales={allLocales}
|
|
307
|
-
firstDay={Number(firstDay)}
|
|
308
|
-
plugins={[dayGridPlugin, timeGridPlugin, interactionPlugin, listPlugin, momentPlugin]}
|
|
309
|
-
headerToolbar={headerToolbar}
|
|
310
|
-
moreLinkClick={(info) => {
|
|
311
|
-
let left = 0;
|
|
312
|
-
const ele = info.jsEvent.target as HTMLElement;
|
|
313
|
-
if (info.view.type === ViewType.DAY) {
|
|
314
|
-
if (info.allDay) {
|
|
315
|
-
left = ele.offsetParent?.parentElement?.offsetLeft || 0;
|
|
316
|
-
} else {
|
|
317
|
-
left = ele.parentElement?.offsetLeft || 0;
|
|
318
|
-
}
|
|
319
|
-
} else {
|
|
320
|
-
if (info.allDay) {
|
|
321
|
-
left = ele.offsetParent?.parentElement?.parentElement?.offsetLeft || 0;
|
|
322
|
-
} else {
|
|
323
|
-
left =
|
|
324
|
-
ele.offsetParent?.parentElement?.parentElement?.parentElement?.offsetLeft || 0;
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
setLeft(left);
|
|
328
|
-
}}
|
|
329
|
-
buttonText={buttonText}
|
|
330
|
-
views={views}
|
|
331
|
-
eventClassNames={() => (!showEventTime ? "no-time" : "")}
|
|
332
|
-
slotLabelFormat={slotLabelFormat}
|
|
333
|
-
viewClassNames={viewClassNames}
|
|
334
|
-
moreLinkText={trans("calendar.more")}
|
|
335
|
-
initialDate={initialDate}
|
|
336
|
-
initialView={defaultView}
|
|
337
|
-
editable={editable}
|
|
338
|
-
selectable={editable}
|
|
339
|
-
selectMirror={false}
|
|
340
|
-
displayEventTime={showEventTime}
|
|
341
|
-
dayMaxEvents={dayMaxEvents}
|
|
342
|
-
eventMaxStack={eventMaxStack || undefined}
|
|
343
|
-
weekends={showWeekends}
|
|
344
|
-
allDaySlot={showAllDay}
|
|
345
|
-
eventContent={renderEventContent}
|
|
346
|
-
select={(info) => handleCreate(info)}
|
|
347
|
-
eventClick={(info) => {
|
|
348
|
-
const event = events.find((item: EventType) => item.id === info.event.id);
|
|
349
|
-
editEvent.current = event;
|
|
350
|
-
setTimeout(() => {
|
|
351
|
-
editEvent.current = undefined;
|
|
352
|
-
}, 500);
|
|
353
|
-
}}
|
|
354
|
-
eventsSet={(info) => {
|
|
355
|
-
let needChange = false;
|
|
356
|
-
let changeEvents: EventType[] = [];
|
|
357
|
-
info.forEach((item) => {
|
|
358
|
-
const event = events.find((i: EventType) => i.id === item.id);
|
|
359
|
-
const start = dayjs(item.start, DateParser).format();
|
|
360
|
-
const end = dayjs(item.end, DateParser).format();
|
|
361
|
-
if (
|
|
362
|
-
start !== event?.start ||
|
|
363
|
-
end !== event?.end ||
|
|
364
|
-
!!item.allDay !== !!event?.allDay
|
|
365
|
-
) {
|
|
366
|
-
needChange = true;
|
|
367
|
-
changeEvents.push({
|
|
368
|
-
...event,
|
|
369
|
-
allDay: item.allDay,
|
|
370
|
-
start: item.startStr,
|
|
371
|
-
end: item.endStr,
|
|
372
|
-
});
|
|
373
|
-
} else {
|
|
374
|
-
changeEvents.push(event);
|
|
375
|
-
}
|
|
376
|
-
});
|
|
377
|
-
if (needChange) {
|
|
378
|
-
props.events.onChange(changeEvents);
|
|
379
|
-
props.onEvent("change");
|
|
380
|
-
}
|
|
381
|
-
}}
|
|
382
|
-
/>
|
|
383
|
-
</Wrapper>
|
|
384
|
-
);
|
|
385
|
-
})
|
|
386
|
-
.setPropertyViewFn((children) => {
|
|
387
|
-
return (
|
|
388
|
-
<>
|
|
389
|
-
<Section name={sectionNames.basic}>{children.events.propertyView({})}</Section>
|
|
390
|
-
<Section name={sectionNames.interaction}>{children.onEvent.getPropertyView()}</Section>
|
|
391
|
-
<Section name={sectionNames.advanced}>
|
|
392
|
-
{children.editable.propertyView({
|
|
393
|
-
label: trans("calendar.editable"),
|
|
394
|
-
})}
|
|
395
|
-
{children.defaultDate.propertyView({
|
|
396
|
-
label: trans("calendar.defaultDate"),
|
|
397
|
-
tooltip: trans("calendar.defaultDateTooltip"),
|
|
398
|
-
})}
|
|
399
|
-
{children.defaultView.propertyView({
|
|
400
|
-
label: trans("calendar.defaultView"),
|
|
401
|
-
tooltip: trans("calendar.defaultViewTooltip"),
|
|
402
|
-
})}
|
|
403
|
-
{children.firstDay.propertyView({
|
|
404
|
-
label: trans("calendar.startWeek"),
|
|
405
|
-
})}
|
|
406
|
-
{children.showEventTime.propertyView({
|
|
407
|
-
label: trans("calendar.showEventTime"),
|
|
408
|
-
tooltip: trans("calendar.showEventTimeTooltip"),
|
|
409
|
-
})}
|
|
410
|
-
{children.showWeekends.propertyView({
|
|
411
|
-
label: trans("calendar.showWeekends"),
|
|
412
|
-
})}
|
|
413
|
-
{children.showAllDay.propertyView({
|
|
414
|
-
label: trans("calendar.showAllDay"),
|
|
415
|
-
tooltip: trans("calendar.showAllDayTooltip"),
|
|
416
|
-
})}
|
|
417
|
-
{children.dayMaxEvents.propertyView({
|
|
418
|
-
label: trans("calendar.dayMaxEvents"),
|
|
419
|
-
tooltip: trans("calendar.dayMaxEventsTooltip"),
|
|
420
|
-
})}
|
|
421
|
-
{children.eventMaxStack.propertyView({
|
|
422
|
-
label: trans("calendar.eventMaxStack"),
|
|
423
|
-
tooltip: trans("calendar.eventMaxStackTooltip"),
|
|
424
|
-
})}
|
|
425
|
-
</Section>
|
|
426
|
-
<Section name={sectionNames.layout}>{hiddenPropertyView(children)}</Section>
|
|
427
|
-
<Section name={sectionNames.style}>{children.style.getPropertyView()}</Section>
|
|
428
|
-
</>
|
|
429
|
-
);
|
|
430
|
-
})
|
|
431
|
-
.build();
|
|
432
|
-
})();
|
|
433
|
-
|
|
434
|
-
CalendarBasicComp = class extends CalendarBasicComp {
|
|
435
|
-
override autoHeight(): boolean {
|
|
436
|
-
return false;
|
|
437
|
-
}
|
|
438
|
-
};
|
|
439
|
-
|
|
440
|
-
export const CalendarComp = withExposingConfigs(CalendarBasicComp, [
|
|
441
|
-
new NameConfig("events", trans("calendar.events")),
|
|
442
|
-
NameConfigHidden,
|
|
443
|
-
]);
|