Skip to content

Commit

Permalink
Merge pull request #1370 from lowcoder-org/remove_lazyload_common_comps
Browse files Browse the repository at this point in the history
remove lazyloading from common components
  • Loading branch information
FalkWolsky authored Dec 4, 2024
2 parents 45f27a4 + 3bbf61b commit b06d729
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,10 @@ const onDrop = async (
const nameGenerator = editorState.getNameGenerator();
const compInfo = parseCompType(compType);
const compName = nameGenerator.genItemName(compInfo.compName);
const isLazyLoadComp = uiCompRegistry[compType as UICompType]?.lazyLoad;
let defaultDataFn = undefined;

if (!compInfo.isRemote) {
if (isLazyLoadComp) {
const {
defaultDataFnName,
defaultDataFnPath,
Expand All @@ -237,6 +238,8 @@ const onDrop = async (
const module = await import(`../../${defaultDataFnPath}.tsx`);
defaultDataFn = module[defaultDataFnName];
}
} else if(!compInfo.isRemote) {
defaultDataFn = uiCompRegistry[compType as UICompType]?.defaultDataFn;
}

const widgetValue: GridItemDataType = {
Expand Down
4 changes: 2 additions & 2 deletions client/packages/lowcoder/src/comps/comps/rootComp.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import "comps/comps/layout/navLayout";
import "comps/comps/layout/mobileTabLayout";
// import "comps/comps/layout/navLayout";
// import "comps/comps/layout/mobileTabLayout";

import { CompAction, CompActionTypes } from "lowcoder-core";
import { EditorContext, EditorState } from "comps/editorState";
Expand Down
62 changes: 27 additions & 35 deletions client/packages/lowcoder/src/comps/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import "comps/comps/layout/navLayout";
import "comps/comps/layout/mobileTabLayout";

import cnchar from "cnchar";
import { trans } from "i18n";
import { remoteComp } from "./comps/remoteComp/remoteComp";
Expand Down Expand Up @@ -113,6 +116,17 @@ import {
KanbanCompIcon,

} from "lowcoder-design";
import { ModuleComp } from "./comps/moduleComp/moduleComp";
import { TableComp } from "./comps/tableComp/tableComp";
import { defaultTableData } from "./comps/tableComp/mockTableComp";
import { ContainerComp, defaultContainerData } from "./comps/containerComp/containerComp";
import { ColumnLayoutComp } from "./comps/columnLayout/columnLayout";
import { TabbedContainerComp } from "./comps/tabs/tabbedContainerComp";
import { ButtonComp } from "./comps/buttonComp/buttonComp";
import { TextComp } from "./comps/textComp";
import { SelectComp } from "./comps/selectInputComp/selectComp";
import { InputComp } from "./comps/textInputComp/inputComp";
import { TextAreaComp } from "./comps/textInputComp/textAreaComp";

type Registry = {
[key in UICompType]?: UICompManifest;
Expand Down Expand Up @@ -340,19 +354,16 @@ export var uiCompMap: Registry = {
name: trans("uiComp.tableCompName"),
enName: "Table",
description: trans("uiComp.tableCompDesc"),
categories: ["dashboards"],
categories: ["dashboards", "projectmanagement"],
icon: TableCompIcon,
keywords: trans("uiComp.tableCompKeywords"),
lazyLoad: true,
compName: "TableComp",
compPath: "comps/tableComp/index",
comp: TableComp,
layoutInfo: {
w: 12,
h: 40,
},
withoutLoading: true,
defaultDataFnName: "defaultTableData",
defaultDataFnPath: "comps/tableComp/mockTableComp",
defaultDataFn: defaultTableData,
},

pivotTable: {
Expand Down Expand Up @@ -450,9 +461,7 @@ export var uiCompMap: Registry = {
categories: ["layout"],
icon: ColumnLayoutCompIcon,
keywords: trans("uiComp.responsiveLayoutCompKeywords"),
lazyLoad: true,
compName: "ColumnLayoutComp",
compPath: "comps/columnLayout/index",
comp: ColumnLayoutComp,
withoutLoading: true,
layoutInfo: {
w: 24,
Expand Down Expand Up @@ -502,9 +511,7 @@ export var uiCompMap: Registry = {
categories: ["layout"],
icon: TabbedContainerCompIcon,
keywords: trans("uiComp.tabbedContainerCompKeywords"),
lazyLoad: true,
compName: "TabbedContainerComp",
compPath: "comps/tabs/index",
comp: TabbedContainerComp,
withoutLoading: true,
layoutInfo: {
w: 12,
Expand Down Expand Up @@ -540,18 +547,15 @@ export var uiCompMap: Registry = {
categories: ["layout"],
icon: ContainerCompIcon,
keywords: trans("uiComp.containerCompKeywords"),
lazyLoad: true,
compName: "ContainerComp",
compPath: "comps/containerComp/containerComp",
comp: ContainerComp,
withoutLoading: true,
layoutInfo: {
w: 12,
h: 25,
// static: true,
delayCollision: true,
},
defaultDataFnName: "defaultContainerData",
defaultDataFnPath: "comps/containerComp/containerComp",
defaultDataFn: defaultContainerData,
},
listView: {
name: trans("uiComp.listViewCompName"),
Expand Down Expand Up @@ -927,9 +931,7 @@ export var uiCompMap: Registry = {
categories: ["forms"],
icon: InputCompIcon,
keywords: trans("uiComp.inputCompKeywords"),
lazyLoad: true,
compName: "InputComp",
compPath: "comps/textInputComp/inputComp",
comp: InputComp,
layoutInfo: {
w: 6,
h: 6,
Expand Down Expand Up @@ -972,9 +974,7 @@ export var uiCompMap: Registry = {
categories: ["forms"],
icon: TextAreaCompIcon,
keywords: trans("uiComp.textAreaCompKeywords"),
lazyLoad: true,
compName: "TextAreaComp",
compPath: "comps/textInputComp/textAreaComp",
comp: TextAreaComp,
layoutInfo: {
w: 6,
h: 12,
Expand Down Expand Up @@ -1141,9 +1141,7 @@ export var uiCompMap: Registry = {
categories: ["forms"],
icon: ButtonCompIcon,
keywords: trans("uiComp.buttonCompKeywords"),
lazyLoad: true,
compName: "ButtonComp",
compPath: "comps/buttonComp/buttonComp",
comp: ButtonComp,
layoutInfo: {
w: 6,
h: 6,
Expand Down Expand Up @@ -1563,9 +1561,7 @@ export var uiCompMap: Registry = {
categories: ["forms", "itemHandling"],
icon: SelectCompIcon,
keywords: trans("uiComp.selectCompKeywords"),
lazyLoad: true,
compName: "SelectComp",
compPath: "comps/selectInputComp/selectComp",
comp: SelectComp,
layoutInfo: {
w: 6,
h: 5,
Expand Down Expand Up @@ -1705,9 +1701,7 @@ export var uiCompMap: Registry = {
description: trans("uiComp.moduleCompDesc"),
categories: [],
keywords: trans("uiComp.moduleCompKeywords"),
lazyLoad: true,
compName: "ModuleComp",
compPath: "comps/moduleComp/moduleComp",
comp: ModuleComp,
layoutInfo: {
w: 12,
h: 40,
Expand All @@ -1723,9 +1717,7 @@ export var uiCompMap: Registry = {
categories: ["dashboards", "layout", "multimedia"],
icon: TextCompIcon,
keywords: trans("uiComp.textCompKeywords"),
compName: "TextComp",
lazyLoad: true,
compPath: "comps/textComp",
comp: TextComp,
layoutInfo: {
w: 6,
h: 24,
Expand Down

0 comments on commit b06d729

Please sign in to comment.