diff --git a/client/packages/lowcoder/src/pages/editor/right/uiCompPanel.tsx b/client/packages/lowcoder/src/pages/editor/right/uiCompPanel.tsx
index 3451c679a..1b854f7cf 100644
--- a/client/packages/lowcoder/src/pages/editor/right/uiCompPanel.tsx
+++ b/client/packages/lowcoder/src/pages/editor/right/uiCompPanel.tsx
@@ -8,23 +8,23 @@ import { draggingUtils } from "layout";
import { isEmpty } from "lodash";
import { language } from "i18n";
import {
- ComListTitle,
CompIconDiv,
EmptyCompContent,
RightPanelContentWrapper,
} from "pages/editor/right/styledComponent";
import { tableDragClassName } from "pages/tutorials/tutorialsConstant";
-import React, { useContext, useMemo } from "react";
+import React, { useContext, useMemo, useState } from "react";
import styled from "styled-components";
-import { labelCss } from "lowcoder-design";
+import {
+ BaseSection,
+ PropertySectionContext,
+ PropertySectionContextType,
+ PropertySectionState,
+ labelCss,
+} from "lowcoder-design";
import { TransparentImg } from "../../../util/commonUtils";
import { RightContext } from "./rightContext";
-const GrayLabel = (props: { label: string }) => {
- const { label } = props;
- return {label};
-};
-
const CompDiv = styled.div`
display: flex;
flex-direction: column;
@@ -80,16 +80,25 @@ const InsertContain = styled.div`
gap: 8px;
`;
-const CategoryLabel = styled(GrayLabel)`
- margin: 0;
-`;
-
const SectionWrapper = styled.div`
- margin-bottom: 16px;
+ .section-header {
+ margin-left: 0;
+ }
+ &:not(:last-child){
+ border-bottom: 1px solid #e1e3eb;
+ }
`;
+const stateCompName = 'UICompSections';
+const initialState: PropertySectionState = { [stateCompName]: {}};
+Object.keys(uiCompCategoryNames).forEach((cat) => {
+ const key = uiCompCategoryNames[cat as UICompCategory];
+ initialState[stateCompName][key] = key === uiCompCategoryNames.common
+})
+
export const UICompPanel = () => {
const { onDrag, searchValue } = useContext(RightContext);
+ const [propertySectionState, setPropertySectionState] = useState(initialState);
const categories = useMemo(() => {
const cats: Record = Object.fromEntries(
@@ -103,6 +112,22 @@ export const UICompPanel = () => {
return cats;
}, []);
+ const propertySectionContextValue = useMemo(() => {
+ return {
+ compName: stateCompName,
+ state: propertySectionState,
+ toggle: (compName: string, sectionName: string) => {
+ setPropertySectionState((oldState) => {
+ const nextSectionState: PropertySectionState = { ...oldState };
+ const compState = nextSectionState[compName] || {};
+ compState[sectionName] = compState[sectionName] === false;
+ nextSectionState[compName] = compState;
+ return nextSectionState;
+ });
+ },
+ };
+ }, [propertySectionState]);
+
const compList = useMemo(
() =>
Object.entries(categories)
@@ -122,26 +147,31 @@ export const UICompPanel = () => {
return (
-
-
- {infos.map((info) => (
-
- {
- e.dataTransfer.setData("compType", info[0]);
- e.dataTransfer.setDragImage(TransparentImg, 0, 0);
- draggingUtils.setData("compType", info[0]);
- onDrag(info[0]);
- }}
- >
-
-
- {info[1].name}
- {language !== "en" && {info[1].enName}}
-
- ))}
-
+
+
+ {infos.map((info) => (
+
+ {
+ e.dataTransfer.setData("compType", info[0]);
+ e.dataTransfer.setDragImage(TransparentImg, 0, 0);
+ draggingUtils.setData("compType", info[0]);
+ onDrag(info[0]);
+ }}
+ >
+
+
+ {info[1].name}
+ {language !== "en" && {info[1].enName}}
+
+ ))}
+
+
);
})
@@ -149,9 +179,20 @@ export const UICompPanel = () => {
[categories, searchValue, onDrag]
);
+ if(!compList.length) return (
+
+
+
+ )
+
return (
- {compList.length > 0 ? compList : }
+ {/* {compList.length > 0 ? compList : } */}
+
+ {compList}
+
);
};