Skip to content

Commit 2a027cd

Browse files
authored
Merge pull request #2105 from iamfaran/feat/1109-nav-tree-items
[Feat]: #1109 nav tree items + navigation fixes
2 parents 5bd5c0b + 5a36d21 commit 2a027cd

File tree

17 files changed

+383
-554
lines changed

17 files changed

+383
-554
lines changed

client/packages/lowcoder-design/src/components/option.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { CSS } from "@dnd-kit/utilities";
99
import { SortableContext, useSortable, verticalListSortingStrategy } from "@dnd-kit/sortable";
1010
import { ConstructorToComp, MultiCompConstructor } from "lowcoder-core";
1111
import { ReactComponent as WarnIcon } from "icons/v1/icon-warning-white.svg";
12-
import { DndContext } from "@dnd-kit/core";
12+
import { DndContext, DragEndEvent } from "@dnd-kit/core";
1313
import { restrictToVerticalAxis } from "@dnd-kit/modifiers";
1414
import { ActiveTextColor, GreyTextColor } from "constants/style";
1515
import { trans } from "i18n/design";
@@ -225,12 +225,12 @@ function Option<T extends ConstructorToComp<MultiCompConstructor>>(props: {
225225
}
226226
return -1;
227227
};
228-
const handleDragEnd = (e: { active: { id: string }; over: { id: string } | null }) => {
228+
const handleDragEnd = (e: DragEndEvent) => {
229229
if (!e.over) {
230230
return;
231231
}
232-
const fromIndex = findIndex(e.active.id);
233-
const toIndex = findIndex(e.over.id);
232+
const fromIndex = findIndex(String(e.active.id));
233+
const toIndex = findIndex(String(e.over.id));
234234
if (fromIndex < 0 || toIndex < 0 || fromIndex === toIndex) {
235235
return;
236236
}

client/packages/lowcoder/package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
"@codemirror/lang-json": "^6.0.1",
1717
"@codemirror/lang-sql": "^6.5.4",
1818
"@codemirror/search": "^6.5.5",
19-
"@dnd-kit/core": "^5.0.1",
19+
"@dnd-kit/core": "^6.3.1",
2020
"@dnd-kit/modifiers": "^7.0.0",
21-
"@dnd-kit/sortable": "^6.0.0",
22-
"@dnd-kit/utilities": "^3.1.0",
21+
"@dnd-kit/sortable": "^10.0.0",
22+
"@dnd-kit/utilities": "^3.2.2",
2323
"@fortawesome/fontawesome-svg-core": "^6.5.1",
2424
"@fortawesome/free-brands-svg-icons": "^6.5.1",
2525
"@fortawesome/free-regular-svg-icons": "^6.5.1",
@@ -48,6 +48,7 @@
4848
"copy-to-clipboard": "^3.3.3",
4949
"core-js": "^3.25.2",
5050
"dayjs": "^1.11.13",
51+
"dnd-kit-sortable-tree": "^0.1.73",
5152
"echarts": "^5.4.3",
5253
"echarts-for-react": "^3.0.2",
5354
"echarts-wordcloud": "^2.1.0",

client/packages/lowcoder/src/comps/comps/formComp/createForm.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import log from "loglevel";
2828
import { Datasource } from "@lowcoder-ee/constants/datasourceConstants";
2929
import DataSourceIcon from "components/DataSourceIcon";
3030
import { messageInstance } from "lowcoder-design/src/components/GlobalInstances";
31-
import { DndContext } from "@dnd-kit/core";
31+
import { DndContext, DragEndEvent } from "@dnd-kit/core";
3232
import { SortableContext, useSortable } from "@dnd-kit/sortable";
3333
import { CSS } from "@dnd-kit/utilities";
3434

@@ -599,7 +599,7 @@ const CreateFormBody = (props: { onCreate: CreateHandler }) => {
599599
setItems(initItems);
600600
}, [dataSourceTypeConfig, tableStructure, form]);
601601

602-
const handleDragEnd = useCallback((e: { active: { id: string }; over: { id: string } | null }) => {
602+
const handleDragEnd = useCallback((e: DragEndEvent) => {
603603
if (!e.over) {
604604
return;
605605
}

client/packages/lowcoder/src/comps/comps/layout/layoutMenuItemComp.tsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { MultiBaseComp } from "lowcoder-core";
22
import { BoolCodeControl, StringControl } from "comps/controls/codeControl";
3-
import { valueComp } from "comps/generators";
3+
import { BoolControl } from "comps/controls/boolControl";
4+
import { valueComp, withPropertyViewFn } from "comps/generators";
45
import { list } from "comps/generators/list";
56
import {
67
parseChildrenFromValueAndChildrenMap,
@@ -16,16 +17,21 @@ import { genRandomKey } from "comps/utils/idGenerator";
1617
import { LayoutActionComp } from "comps/comps/layout/layoutActionComp";
1718
import { migrateOldData } from "comps/generators/simpleGenerators";
1819

20+
// BoolControl without property view (internal state only)
21+
const CollapsedControl = withPropertyViewFn(BoolControl, () => null);
22+
1923
const childrenMap = {
2024
label: StringControl,
2125
hidden: BoolCodeControl,
2226
action: LayoutActionComp,
27+
collapsed: CollapsedControl, // tree editor collapsed state
2328
itemKey: valueComp<string>(""),
2429
icon: IconControl,
2530
};
2631

2732
type ChildrenType = ToInstanceType<typeof childrenMap> & {
2833
items: InstanceType<typeof LayoutMenuItemListComp>;
34+
collapsed: InstanceType<typeof CollapsedControl>;
2935
};
3036

3137
/**
@@ -73,6 +79,14 @@ export class LayoutMenuItemComp extends MultiBaseComp<ChildrenType> {
7379
getItemKey() {
7480
return this.children.itemKey.getView();
7581
}
82+
83+
getCollapsed(): boolean {
84+
return this.children.collapsed.getView();
85+
}
86+
87+
setCollapsed(collapsed: boolean) {
88+
this.children.collapsed.dispatchChangeValueAction(collapsed);
89+
}
7690
}
7791

7892
const LayoutMenuItemCompMigrate = migrateOldData(LayoutMenuItemComp, (oldData: any) => {

client/packages/lowcoder/src/comps/comps/layout/navLayout.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,12 @@ let NavTmpLayout = (function () {
247247
{
248248
label: trans("menuItem") + " 1",
249249
itemKey: genRandomKey(),
250+
items: [
251+
{
252+
label: trans("subMenuItem") + " 1",
253+
itemKey: genRandomKey(),
254+
},
255+
],
250256
},
251257
]),
252258
jsonItems: jsonControl(convertTreeData, jsonMenuItems),

client/packages/lowcoder/src/comps/comps/listViewComp/listView.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { useMergeCompStyles } from "@lowcoder-ee/util/hooks";
2222
import { childrenToProps } from "@lowcoder-ee/comps/generators/multi";
2323
import { AnimationStyleType } from "@lowcoder-ee/comps/controls/styleControlConstants";
2424
import { getBackgroundStyle } from "@lowcoder-ee/util/styleUtils";
25-
import { DndContext } from "@dnd-kit/core";
25+
import { DndContext, DragEndEvent } from "@dnd-kit/core";
2626
import { SortableContext, useSortable } from "@dnd-kit/sortable";
2727
import { CSS } from "@dnd-kit/utilities";
2828
import { JSONObject } from "@lowcoder-ee/util/jsonTypes";
@@ -354,7 +354,7 @@ export function ListView(props: Props) {
354354

355355
useMergeCompStyles(childrenProps, comp.dispatch);
356356

357-
const handleDragEnd = (e: { active: { id: string }; over: { id: string } | null }) => {
357+
const handleDragEnd = (e: DragEndEvent) => {
358358
if (!e.over) {
359359
return;
360360
}

client/packages/lowcoder/src/comps/comps/navComp/components/DraggableItem.tsx

Lines changed: 0 additions & 106 deletions
This file was deleted.

client/packages/lowcoder/src/comps/comps/navComp/components/DroppableMenuItem.tsx

Lines changed: 0 additions & 130 deletions
This file was deleted.

0 commit comments

Comments
 (0)