1
1
import { CompParams } from "lowcoder-core" ;
2
2
import { ToDataType } from "comps/generators/multi" ;
3
- import { NameConfigHidden , withExposingConfigs } from "comps/generators/withExposing" ;
3
+ import { NameConfigDisabled , NameConfigHidden , withExposingConfigs , NameConfig , CompDepsConfig } from "comps/generators/withExposing" ;
4
+ import { withMethodExposing } from "comps/generators/withMethodExposing" ;
4
5
import { NameGenerator } from "comps/utils/nameGenerator" ;
5
6
import { Section , sectionNames } from "lowcoder-design" ;
6
7
import { oldContainerParamsToNew } from "../containerBase" ;
@@ -9,7 +10,7 @@ import { disabledPropertyView, hiddenPropertyView } from "comps/utils/propertyUt
9
10
import { trans } from "i18n" ;
10
11
import { BoolCodeControl } from "comps/controls/codeControl" ;
11
12
import { DisabledContext } from "comps/generators/uiCompBuilder" ;
12
- import React , { useContext } from "react" ;
13
+ import React , { useContext , useEffect , useState } from "react" ;
13
14
import { EditorContext } from "comps/editorState" ;
14
15
15
16
import {
@@ -18,14 +19,19 @@ import {
18
19
} from "../pageLayoutComp/pageLayoutCompBuilder" ;
19
20
import { PageLayout } from "../pageLayoutComp/pageLayout" ;
20
21
22
+
21
23
export const ContainerBaseComp = ( function ( ) {
22
- const childrenMap = {
23
- disabled : BoolCodeControl ,
24
+ const childrenMap = {
25
+ disabled : BoolCodeControl
24
26
} ;
27
+
25
28
return new ContainerCompBuilder ( childrenMap , ( props , dispatch ) => {
29
+
30
+ const [ siderCollapsed , setSiderCollapsed ] = useState ( false ) ;
31
+
26
32
return (
27
33
< DisabledContext . Provider value = { props . disabled } >
28
- < PageLayout { ...props } />
34
+ < PageLayout { ...props } siderCollapsed = { siderCollapsed } setSiderCollapsed = { setSiderCollapsed } />
29
35
</ DisabledContext . Provider >
30
36
) ;
31
37
} )
@@ -102,13 +108,41 @@ function convertOldContainerParams(params: CompParams<any>) {
102
108
return tempParams ;
103
109
}
104
110
111
+
105
112
class ContainerTmpComp extends ContainerBaseComp {
106
113
constructor ( params : CompParams < any > ) {
107
114
super ( convertOldContainerParams ( params ) ) ;
108
115
}
109
116
}
110
117
111
- export const PageLayoutComp = withExposingConfigs ( ContainerTmpComp , [ NameConfigHidden ] ) ;
118
+ const PageLayoutCompTmP = withExposingConfigs ( ContainerTmpComp , [
119
+ NameConfigHidden ,
120
+ NameConfigDisabled ,
121
+
122
+ new NameConfig ( "container" , trans ( "export.ratingValueDesc" ) ) ,
123
+ new CompDepsConfig (
124
+ "siderCollapsed" ,
125
+ ( comp ) => ( { data : comp . children . container . children . siderCollapsed . nodeWithoutCache ( ) } ) ,
126
+ ( input ) => input . data . value , trans ( "listView.itemsDesc" )
127
+ ) ,
128
+ ] ) ;
129
+
130
+ export const PageLayoutComp = withMethodExposing ( PageLayoutCompTmP , [
131
+
132
+ {
133
+ method : {
134
+ name : "setSiderCollapsed" ,
135
+ description : "Set the Sider of the PageLayout to be collapsed or not" ,
136
+ params : [ { name : "collapsed" , type : "boolean" } ] ,
137
+ } ,
138
+ execute : ( comp , values ) => {
139
+ const page = values [ 0 ] as number ;
140
+ if ( page && page > 0 ) {
141
+ // comp.children.pagination.children.pageNo.dispatchChangeValueAction(page);
142
+ }
143
+ } ,
144
+ }
145
+ ] ) ;
112
146
113
147
type ContainerDataType = ToDataType < ContainerChildren < { } > > ;
114
148
@@ -121,10 +155,40 @@ export function defaultPageLayoutData(
121
155
header : toSimpleContainerData ( [
122
156
{
123
157
item : {
124
- compType : "text " ,
125
- name : nameGenerator . genItemName ( "containerTitle " ) ,
158
+ compType : "navigation " ,
159
+ name : nameGenerator . genItemName ( "pageNavigation " ) ,
126
160
comp : {
127
- text : "## " + trans ( "container.title" ) ,
161
+ logoUrl : "" ,
162
+ hidden : false ,
163
+ items : [
164
+ {
165
+ label : "Home" ,
166
+ hidden : false ,
167
+ active : false ,
168
+ } ,
169
+ {
170
+ label : "Services" ,
171
+ hidden : false ,
172
+ active : false ,
173
+ items : [
174
+ {
175
+ label : "Lowcode Platform" ,
176
+ hidden : false ,
177
+ active : false ,
178
+ } ,
179
+ {
180
+ label : "App Development" ,
181
+ hidden : false ,
182
+ active : false ,
183
+ } ,
184
+ ] ,
185
+ } ,
186
+ {
187
+ label : "About" ,
188
+ hidden : false ,
189
+ active : false ,
190
+ } ,
191
+ ] ,
128
192
} ,
129
193
} ,
130
194
layoutItem : {
0 commit comments