Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6e080c6

Browse files
fix: initially show only commonly used comps
1 parent436283f commit6e080c6

File tree

1 file changed

+40
-2
lines changed

1 file changed

+40
-2
lines changed

‎client/packages/lowcoder/src/pages/editor/right/uiCompPanel.tsx‎

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,13 @@ import {
1313
RightPanelContentWrapper,
1414
}from"pages/editor/right/styledComponent";
1515
import{tableDragClassName}from"pages/tutorials/tutorialsConstant";
16-
importReact,{useContext,useMemo}from"react";
16+
importReact,{useContext,useMemo,useState}from"react";
1717
importstyledfrom"styled-components";
1818
import{
1919
BaseSection,
20+
PropertySectionContext,
21+
PropertySectionContextType,
22+
PropertySectionState,
2023
labelCss,
2124
}from"lowcoder-design";
2225
import{TransparentImg}from"../../../util/commonUtils";
@@ -83,8 +86,16 @@ const SectionWrapper = styled.div`
8386
}
8487
`;
8588

89+
conststateCompName='UICompSections';
90+
constinitialState:PropertySectionState={[stateCompName]:{}};
91+
Object.keys(uiCompCategoryNames).forEach((cat)=>{
92+
constkey=uiCompCategoryNames[catasUICompCategory];
93+
initialState[stateCompName][key]=key===uiCompCategoryNames.common
94+
})
95+
8696
exportconstUICompPanel=()=>{
8797
const{ onDrag, searchValue}=useContext(RightContext);
98+
const[propertySectionState,setPropertySectionState]=useState<PropertySectionState>(initialState);
8899

89100
constcategories=useMemo(()=>{
90101
constcats:Record<string,[string,UICompManifest][]>=Object.fromEntries(
@@ -98,6 +109,22 @@ export const UICompPanel = () => {
98109
returncats;
99110
},[]);
100111

112+
constpropertySectionContextValue=useMemo<PropertySectionContextType>(()=>{
113+
return{
114+
compName:stateCompName,
115+
state:propertySectionState,
116+
toggle:(compName:string,sectionName:string)=>{
117+
setPropertySectionState((oldState)=>{
118+
constnextSectionState:PropertySectionState={ ...oldState};
119+
constcompState=nextSectionState[compName]||{};
120+
compState[sectionName]=compState[sectionName]===false;
121+
nextSectionState[compName]=compState;
122+
returnnextSectionState;
123+
});
124+
},
125+
};
126+
},[propertySectionState]);
127+
101128
constcompList=useMemo(
102129
()=>
103130
Object.entries(categories)
@@ -149,9 +176,20 @@ export const UICompPanel = () => {
149176
[categories,searchValue,onDrag]
150177
);
151178

179+
if(!compList.length)return(
180+
<RightPanelContentWrapper>
181+
<EmptyCompContent/>
182+
</RightPanelContentWrapper>
183+
)
184+
152185
return(
153186
<RightPanelContentWrapper>
154-
{compList.length>0 ?compList :<EmptyCompContent/>}
187+
{/* {compList.length > 0 ? compList : <EmptyCompContent />} */}
188+
<PropertySectionContext.Provider
189+
value={propertySectionContextValue}
190+
>
191+
{compList}
192+
</PropertySectionContext.Provider>
155193
</RightPanelContentWrapper>
156194
);
157195
};

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp