Skip to content

Commit d31ff44

Browse files
authored
Merge branch 'dev' into ee-setup
2 parents b1a3cfe + 335b513 commit d31ff44

File tree

16 files changed

+354
-302
lines changed

16 files changed

+354
-302
lines changed

client/packages/lowcoder-comps/src/comps/calendarComp/calendarComp.tsx

Lines changed: 57 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ let CalendarBasicComp = (function () {
306306
...(item.groupId ? { groupId: item.groupId } : {}),
307307
backgroundColor: item.backgroundColor,
308308
extendedProps: { // Ensure color is in extendedProps
309-
color: isValidColor(item.color || "") ? item.color : theme?.theme?.primary,
309+
color: isValidColor(item.color || "") ? item.color : theme?.theme?.primary,
310310
detail: item.detail,
311311
titleColor:item.titleColor,
312312
detailColor:item.detailColor,
@@ -324,22 +324,13 @@ let CalendarBasicComp = (function () {
324324
}, [currentEvents, theme])
325325

326326
useEffect(() => {
327+
if (initData.current) return;
328+
327329
const mapData: Record<string, number> = {};
328330
events?.forEach((item: any, index: number) => {
329331
mapData[`${item.id}`] = index;
330332
})
331333

332-
if (initData.current) {
333-
const difference = differenceWith(events, props.initialData, isEqual);
334-
const inserted = differenceBy(difference, Object.keys(initDataMap)?.map(id => ({ id })), 'id')
335-
const updated = filter(difference, obj => includes(Object.keys(initDataMap), String(obj.id)));
336-
const deleted = differenceBy(props.initialData, Object.keys(mapData)?.map(id => ({ id })), 'id')
337-
338-
comp.children?.comp.children?.updatedEvents.dispatchChangeValueAction(updated);
339-
comp.children?.comp.children?.insertedEvents.dispatchChangeValueAction(inserted);
340-
comp.children?.comp.children?.deletedEvents.dispatchChangeValueAction(deleted);
341-
}
342-
343334
if (!initData.current && events?.length && comp?.children?.comp?.children?.initialData) {
344335
setInitDataMap(mapData);
345336
comp?.children?.comp?.children?.initialData?.dispatch?.(
@@ -407,7 +398,54 @@ let CalendarBasicComp = (function () {
407398
}
408399
}, [slotLabelFormat, slotLabelFormatWeek, slotLabelFormatMonth]);
409400

410-
const handleEventDataChange = useCallback((data: Array<Record<string,any>>) => {
401+
const findUpdatedInsertedDeletedEvents = useCallback((data: Array<EventType>) => {
402+
if (!initData.current) return;
403+
404+
let eventsData: Array<Record<string, any>> = currentView == "resourceTimelineDay" || currentView == "resourceTimeGridDay"
405+
? data.filter((event: { resourceId?: string; }) => Boolean(event.resourceId))
406+
: data.filter((event: { resourceId?: string; }) => !Boolean(event.resourceId));
407+
408+
eventsData = eventsData.map((item) => ({
409+
title: item.label,
410+
id: item.id,
411+
start: dayjs(item.start, DateParser).format(),
412+
end: dayjs(item.end, DateParser).format(),
413+
allDay: item.allDay,
414+
...(item.resourceId ? { resourceId: item.resourceId } : {}),
415+
...(item.groupId ? { groupId: item.groupId } : {}),
416+
backgroundColor: item.backgroundColor,
417+
extendedProps: { // Ensure color is in extendedProps
418+
color: isValidColor(item.color || "") ? item.color : theme?.theme?.primary,
419+
detail: item.detail,
420+
titleColor:item.titleColor,
421+
detailColor:item.detailColor,
422+
titleFontWeight:item.titleFontWeight,
423+
titleFontStyle:item.titleFontStyle,
424+
detailFontWeight:item.detailFontWeight,
425+
detailFontStyle:item.detailFontStyle,
426+
animation:item?.animation,
427+
animationDelay:item?.animationDelay,
428+
animationDuration:item?.animationDuration,
429+
animationIterationCount:item?.animationIterationCount
430+
}
431+
}));
432+
433+
const mapData: Record<string, number> = {};
434+
eventsData?.forEach((item: any, index: number) => {
435+
mapData[`${item.id}`] = index;
436+
})
437+
438+
const difference = differenceWith(eventsData, props.initialData, isEqual);
439+
const inserted = differenceBy(difference, Object.keys(initDataMap)?.map(id => ({ id })), 'id')
440+
const updated = filter(difference, obj => includes(Object.keys(initDataMap), String(obj.id)));
441+
const deleted = differenceBy(props.initialData, Object.keys(mapData)?.map(id => ({ id })), 'id')
442+
443+
comp?.children?.comp?.children?.updatedEvents.dispatchChangeValueAction(updated);
444+
comp?.children?.comp?.children?.insertedEvents.dispatchChangeValueAction(inserted);
445+
comp?.children?.comp?.children?.deletedEvents.dispatchChangeValueAction(deleted);
446+
}, [initDataMap, currentView, props.initialData, initData.current]);
447+
448+
const handleEventDataChange = useCallback((data: Array<EventType>) => {
411449
comp?.children?.comp.children.events.children.manual.children.manual.dispatch(
412450
comp?.children?.comp.children.events.children.manual.children.manual.setChildrensAction(
413451
data
@@ -416,6 +454,9 @@ let CalendarBasicComp = (function () {
416454
comp?.children?.comp.children.events.children.mapData.children.data.dispatchChangeValueAction(
417455
JSON.stringify(data)
418456
);
457+
458+
findUpdatedInsertedDeletedEvents(data);
459+
419460
props.onEvent("change");
420461
}, [comp, props.onEvent]);
421462

@@ -955,9 +996,9 @@ let CalendarBasicComp = (function () {
955996
changeEvents.push(event);
956997
}
957998
});
958-
if (needChange) {
959-
props.onEvent("change");
960-
}
999+
// if (needChange) {
1000+
// props.onEvent("change");
1001+
// }
9611002
}}
9621003
eventDragStart={() => {
9631004
if (typeof props.onDropEvent === 'function') {

client/packages/lowcoder/src/comps/generators/hookToComp.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export function hookToComp(useHookFn: () => JSONObject) {
1313
}),
1414
(comp) => {
1515
const hookValue = useHookFn();
16+
1617
useEffect(() => {
1718
comp.children.value.dispatchChangeValueAction(hookValue);
1819
}, [hookValue]);
@@ -33,8 +34,10 @@ export function hookToStateComp(useHookFn: () => JSONObject) {
3334
(comp) => {
3435
const hookValue = useHookFn();
3536
useEffect(() => {
36-
comp.children.stateValue.dispatchChangeValueAction(hookValue);
37-
}, [hookValue]);
37+
if (hookValue !== comp.children.stateValue.getView()) {
38+
comp.children.stateValue.dispatchChangeValueAction(hookValue);
39+
}
40+
}, []);
3841
return null;
3942
}
4043
);

client/packages/lowcoder/src/comps/generators/withMultiContext.tsx

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@ import _ from "lodash";
22
import {
33
Comp,
44
CompAction,
5+
CompActionTypes,
56
CompParams,
67
ConstructorToComp,
78
ConstructorToNodeType,
89
customAction,
910
deferAction,
1011
isChildAction,
12+
isCustomAction,
1113
isMyCustomAction,
1214
MultiBaseComp,
1315
MultiCompConstructor,
@@ -23,6 +25,7 @@ import { JSONValue } from "util/jsonTypes";
2325
import { setFieldsNoTypeCheck } from "util/objectUtils";
2426
import { map } from "./map";
2527
import { paramsEqual, withParamsWithDefault } from "./withParams";
28+
import { LazyCompReadyAction } from "../comps/lazyLoadComp/lazyLoadComp";
2629

2730
export const COMP_KEY = "__comp__";
2831
export const MAP_KEY = "__map__";
@@ -160,8 +163,11 @@ export function withMultiContext<TCtor extends MultiCompConstructor>(VariantComp
160163
} else if (
161164
isChildAction(action) &&
162165
action.path[0] === MAP_KEY &&
163-
!_.isNil(action.path[1]) &&
164-
!thisCompMap.hasOwnProperty(action.path[1])
166+
!_.isNil(action.path[1])
167+
&& (
168+
!thisCompMap.hasOwnProperty(action.path[1])
169+
|| isCustomAction<LazyCompReadyAction>(action, "LazyCompReady")
170+
)
165171
) {
166172
/**
167173
* a virtual path is activated, should generate a new comp in __map__
@@ -171,17 +177,16 @@ export function withMultiContext<TCtor extends MultiCompConstructor>(VariantComp
171177
const params = comp.cacheParamsMap.get(key);
172178
if (params) {
173179
const childComp = comp
174-
.getOriginalComp()
180+
.getComp(key)!
175181
.setParams(params)
176182
.changeDispatch(wrapDispatch(wrapDispatch(comp.dispatch, MAP_KEY), key));
177183
const newChildComp = childComp.reduce(childAction);
178-
if (childComp !== newChildComp) {
179-
const comps = { [key]: newChildComp };
180-
comp = comp.setChild(
181-
MAP_KEY,
182-
comp.children[MAP_KEY].reduce(MapCtor.batchSetCompAction(comps))
183-
);
184-
}
184+
185+
const comps = { [key]: newChildComp };
186+
comp = comp.setChild(
187+
MAP_KEY,
188+
comp.children[MAP_KEY].reduce(MapCtor.batchSetCompAction(comps))
189+
);
185190
}
186191
} else {
187192
comp = super.reduce(action);

client/packages/lowcoder/src/pages/ComponentDoc/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
import { ExampleContext } from "./ExampleContext";
1515
import { trans } from "i18n";
1616
import { Helmet } from "react-helmet";
17+
import { LoadingBarHideTrigger } from "@lowcoder-ee/util/hideLoading";
1718

1819
type CompInfo = UICompManifest & { key: string };
1920
const groups: Partial<Record<UICompCategory, CompInfo[]>> = {};
@@ -109,6 +110,7 @@ export default function ComponentDoc() {
109110
<link rel="iframely" type="text/html" href={window.location.href} media="(aspect-ratio: 1280/720)"/>,
110111
</Helmet>
111112
<Wrapper>
113+
<LoadingBarHideTrigger />
112114
<div className="main">
113115
<div className="sidebar">
114116
<div className="search">

client/packages/lowcoder/src/pages/ComponentPlayground/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { EditorContext, EditorState } from "comps/editorState";
88
import { RootComp } from "comps/comps/rootComp";
99
import { useMemo } from "react";
1010
import { lazyLoadComp } from "@lowcoder-ee/comps/comps/lazyLoadComp/lazyLoadComp";
11+
import { LoadingBarHideTrigger } from "@lowcoder-ee/util/hideLoading";
1112

1213
type CompInfo = UICompManifest & { key: string };
1314
const groups: Partial<Record<UICompCategory, CompInfo[]>> = {};
@@ -72,6 +73,7 @@ export default function ComponentPlayground() {
7273

7374
return (
7475
<Wrapper>
76+
<LoadingBarHideTrigger />
7577
<div className="content">
7678
<EditorContext.Provider value={editorState}>
7779
<CompPlayground

client/packages/lowcoder/src/pages/editor/appEditorInternal.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ function useSaveComp(
4444
const dispatch = useDispatch();
4545
const [prevComp, setPrevComp] = useState<Comp>();
4646
const [prevJsonStr, setPrevJsonStr] = useState<string>();
47+
const [prevAppId, setPrevAppId] = useState<string>();
4748

4849
useEffect(() => {
4950
if (readOnly || blockEditing) {
@@ -54,7 +55,7 @@ function useSaveComp(
5455
}
5556
const curJson = comp.toJsonValue();
5657
const curJsonStr = JSON.stringify(curJson);
57-
if (prevJsonStr === curJsonStr) {
58+
if (prevJsonStr === curJsonStr || (Boolean(prevAppId) && prevAppId !== applicationId)) {
5859
return;
5960
}
6061
// the first time is a normal change, the latter is the manual update
@@ -70,7 +71,8 @@ function useSaveComp(
7071
}
7172
setPrevComp(comp);
7273
setPrevJsonStr(curJsonStr);
73-
}, [comp, applicationId, prevComp, prevJsonStr, readOnly, dispatch]);
74+
setPrevAppId(applicationId);
75+
}, [comp, prevAppId, applicationId, prevComp, prevJsonStr, readOnly, dispatch]);
7476
}
7577

7678
interface AppEditorInternalViewProps {

client/packages/lowcoder/src/pages/setting/theme/ThemeCompPanel.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,9 @@ export const ThemeCompPanel = (props: any) => {
194194
}
195195
},
196196
}) as any;
197-
await newComp.load();
197+
if (compInfo.lazyLoad) {
198+
await newComp.load();
199+
}
198200
}
199201

200202
if (newComp) {

0 commit comments

Comments
 (0)