Skip to content

Commit 25f6915

Browse files
authored
Merge branch 'dev' into fix/style-issues
2 parents 34a1b51 + e944ae0 commit 25f6915

File tree

6 files changed

+38
-21
lines changed

6 files changed

+38
-21
lines changed

client/packages/lowcoder/src/comps/comps/lazyLoadComp/lazyLoadComp.tsx

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,18 @@ function ViewLoading(props: { padding?: number }) {
3838
);
3939
}
4040

41-
interface RemoteCompReadyAction {
42-
type: "RemoteCompReady";
41+
export interface LazyCompReadyAction {
42+
type: "LazyCompReady";
4343
comp: Comp;
4444
}
4545

46-
interface RemoteCompViewProps {
46+
interface LazyCompViewProps {
4747
loadComp: () => Promise<void>;
4848
loadingElement?: () => React.ReactNode;
4949
errorElement?: (error: any) => React.ReactNode;
5050
}
5151

52-
function RemoteCompView(props: React.PropsWithChildren<RemoteCompViewProps>) {
52+
function LazyCompView(props: React.PropsWithChildren<LazyCompViewProps>) {
5353
const { loadComp, loadingElement, errorElement } = props;
5454
const [error, setError] = useState<any>("");
5555

@@ -103,14 +103,14 @@ export function lazyLoadComp(
103103
if (!compPath) {
104104
return;
105105
}
106-
let RemoteExportedComp;
106+
let LazyExportedComp;
107107
if (!loader) {
108108
const module = await import(`../../${compPath}.tsx`);
109-
RemoteExportedComp = module[compName!];
109+
LazyExportedComp = module[compName!];
110110
} else {
111-
RemoteExportedComp = await loader();
111+
LazyExportedComp = await loader();
112112
}
113-
if (!RemoteExportedComp) {
113+
if (!LazyExportedComp) {
114114
log.error("loader not found, lazy load info:", compPath);
115115
return;
116116
}
@@ -122,12 +122,12 @@ export function lazyLoadComp(
122122
if (this.compValue) {
123123
params.value = this.compValue;
124124
}
125-
const RemoteCompWithErrorBound = withErrorBoundary(RemoteExportedComp);
125+
const LazyCompWithErrorBound = withErrorBoundary(LazyExportedComp);
126126
this.dispatch(
127-
customAction<RemoteCompReadyAction>(
127+
customAction<LazyCompReadyAction>(
128128
{
129-
type: "RemoteCompReady",
130-
comp: new RemoteCompWithErrorBound(params),
129+
type: "LazyCompReady",
130+
comp: new LazyCompWithErrorBound(params),
131131
},
132132
false
133133
)
@@ -138,7 +138,7 @@ export function lazyLoadComp(
138138
// const key = `${remoteInfo?.packageName}-${remoteInfo?.packageVersion}-${remoteInfo?.compName}`;
139139
const key = `${compName}`;
140140
return (
141-
<RemoteCompView key={key} loadComp={() => this.load()} loadingElement={loadingElement} />
141+
<LazyCompView key={key} loadComp={() => this.load()} loadingElement={loadingElement} />
142142
);
143143
}
144144

@@ -147,7 +147,7 @@ export function lazyLoadComp(
147147
}
148148

149149
reduce(action: CompAction<any>): this {
150-
if (isCustomAction<RemoteCompReadyAction>(action, "RemoteCompReady")) {
150+
if (isCustomAction<LazyCompReadyAction>(action, "LazyCompReady")) {
151151
// use real remote comp instance to replace RemoteCompLoader
152152
return action.value.comp as this;
153153
}

client/packages/lowcoder/src/comps/comps/moduleComp/moduleComp.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ type UpdateDslAction = {
6868
moduleDsl: Record<string, DSLType>;
6969
};
7070

71-
type ModuleReadyAction = {
71+
export type ModuleReadyAction = {
7272
type: "moduleReady";
7373
comp: RootComp;
7474
};
@@ -263,7 +263,6 @@ class ModuleTmpComp extends ModuleCompBase {
263263

264264
override reduce(action: CompAction<JSONValue>): this {
265265
const appId = this.children.appId.getView();
266-
267266
// init
268267
if (isMyCustomAction<InitAction>(action, "init")) {
269268
if (getReduceContext().disableUpdateState) return this;

client/packages/lowcoder/src/comps/comps/tableComp/expansionControl.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ let ExpansionControlTmp = (function () {
5050
slot: ContextSlotControl,
5151
},
5252
() => ({ expandableConfig: {}, expandModalView: null })
53-
)
53+
)
5454
.setControlItemData({ filterText: label })
5555
.setPropertyViewFn((children, dispatch) => {
5656
return (

client/packages/lowcoder/src/comps/controls/slotControl.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { BackgroundColorContext } from "comps/utils/backgroundColorContext";
1010
import { CanvasContainerID } from "constants/domLocators";
1111
import { Layers } from "constants/Layers";
1212
import { trans } from "i18n";
13-
import { changeChildAction, ConstructorToView } from "lowcoder-core";
13+
import { changeChildAction, CompActionTypes, ConstructorToView } from "lowcoder-core";
1414
import { HintPlaceHolder, TacoButton } from "lowcoder-design";
1515
import { createContext, useContext } from "react";
1616
import styled from "styled-components";

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export function withMultiContext<TCtor extends MultiCompConstructor>(VariantComp
8787
override parseChildrenFromValue(params: CompParams): ChildrenType {
8888
const dispatch = params.dispatch ?? _.noop;
8989
const newParams = { ...params, dispatch: wrapDispatch(dispatch, COMP_KEY) };
90-
90+
9191
const comp: WithParamComp = new WithParamCompCtor(newParams) as unknown as WithParamComp;
9292
const mapComp = new MapCtor({ dispatch: wrapDispatch(dispatch, MAP_KEY) });
9393
return { [COMP_KEY]: comp, [MAP_KEY]: mapComp };

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

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import _ from "lodash";
22
import {
33
CompAction,
44
customAction,
5+
isCustomAction,
56
isMyCustomAction,
67
MultiCompConstructor,
78
wrapChildAction,
@@ -11,6 +12,8 @@ import { ReactNode } from "react";
1112
import { lastValueIfEqual, setFieldsNoTypeCheck } from "util/objectUtils";
1213
import { COMP_KEY, MAP_KEY, withMultiContext } from "./withMultiContext";
1314
import { paramsEqual } from "./withParams";
15+
import { LazyCompReadyAction } from "../comps/lazyLoadComp/lazyLoadComp";
16+
import { ModuleReadyAction } from "../comps/moduleComp/moduleComp";
1417

1518
const SELECTED_KEY = "SELECTED";
1619

@@ -69,19 +72,34 @@ export function withSelectedMultiContext<TCtor extends MultiCompConstructor>(
6972
comp.getOriginalComp().setParams(comp.cacheParamsMap.get(selection)!)
7073
);
7174
}
72-
} else if (!action.editDSL || action.path[0] !== MAP_KEY || _.isNil(action.path[1])) {
75+
} else if ((
76+
!action.editDSL
77+
&& !isCustomAction<LazyCompReadyAction>(action, "LazyCompReady")
78+
&& !isCustomAction<ModuleReadyAction>(action, "moduleReady")
79+
) || action.path[0] !== MAP_KEY || _.isNil(action.path[1])
80+
) {
7381
if (action.path[0] === MAP_KEY && action.path[1] === SELECTED_KEY) {
7482
action.path[1] = this.selection;
7583
}
7684
comp = super.reduce(action);
77-
} else if (action.editDSL && action.path[1] === SELECTED_KEY) {
85+
} else if ((
86+
action.editDSL
87+
|| isCustomAction<LazyCompReadyAction>(action, "LazyCompReady")
88+
|| isCustomAction<ModuleReadyAction>(action, "moduleReady")
89+
) && action.path[1] === SELECTED_KEY) {
7890
// broadcast
7991
const newAction = {
8092
...action,
8193
path: action.path.slice(2),
8294
};
8395
comp = comp.reduce(WithMultiContextComp.forEachAction(newAction));
8496
comp = comp.reduce(wrapChildAction(COMP_KEY, newAction));
97+
} else if (
98+
!action.editDSL
99+
&& isCustomAction<ModuleReadyAction>(action, "moduleReady")
100+
&& action.path[0] === MAP_KEY
101+
) {
102+
comp = super.reduce(action);
85103
}
86104

87105
// console.info("exit withSelectedMultiContext reduce. action: ", action, "\nthis:", this, "\ncomp:", comp);

0 commit comments

Comments
 (0)