1
- import { CompAction , RecordConstructorToView , changeChildAction } from "lowcoder-core" ;
1
+ import { CompAction , RecordConstructorToComp , RecordConstructorToView , changeChildAction } from "lowcoder-core" ;
2
2
import { BoolControl } from "comps/controls/boolControl" ;
3
3
import { arrayObjectExposingStateControl , arrayStringExposingStateControl } from "comps/controls/codeStateControl" ;
4
4
import { styleControl } from "comps/controls/styleControl" ;
5
5
import { TransferStyle , TransferStyleType , heightCalculator , widthCalculator } from "comps/controls/styleControlConstants" ;
6
- import { UICompBuilder } from "comps/generators/uiCompBuilder" ;
6
+ import { NewChildren , UICompBuilder } from "comps/generators/uiCompBuilder" ;
7
7
import { NameConfig , NameConfigHidden , withExposingConfigs } from "comps/generators/withExposing" ;
8
8
import { Section , sectionNames } from "lowcoder-design" ;
9
9
import { hiddenPropertyView , showDataLoadingIndicatorsPropertyView } from "comps/utils/propertyUtils" ;
@@ -17,6 +17,7 @@ import styled, { css } from "styled-components";
17
17
import { useContext , useEffect , useRef , useState } from "react" ;
18
18
import { valueComp , withDefault } from "../generators" ;
19
19
import type { TransferDirection } from 'antd/es/transfer' ;
20
+ import React from "react" ;
20
21
21
22
const Container = styled . div < { $style : TransferStyleType } > `
22
23
height: 100%;
@@ -71,7 +72,9 @@ const childrenMap = {
71
72
searchInfo : valueComp < string [ ] > ( [ '' , '' ] ) ,
72
73
} ;
73
74
74
- const TransferView = ( props : RecordConstructorToView < typeof childrenMap > & {
75
+ type ChildrenType = NewChildren < RecordConstructorToComp < typeof childrenMap > > ;
76
+
77
+ const TransferView = React . memo ( ( props : RecordConstructorToView < typeof childrenMap > & {
75
78
dispatch : ( action : CompAction ) => void ;
76
79
} ) => {
77
80
const conRef = useRef < HTMLDivElement > ( null ) ;
@@ -136,48 +139,54 @@ const TransferView = (props: RecordConstructorToView<typeof childrenMap> & {
136
139
</ Container >
137
140
</ ReactResizeDetector >
138
141
) ;
139
- } ;
142
+ } ) ;
143
+
144
+ const TransferCompPropertyView = React . memo ( ( props : {
145
+ children : ChildrenType
146
+ } ) => {
147
+ return (
148
+ < >
149
+ < Section name = { sectionNames . basic } >
150
+ { props . children . items . propertyView ( {
151
+ label : trans ( "transfer.items" ) ,
152
+ } ) }
153
+ { props . children . targetKeys . propertyView ( {
154
+ label : trans ( "transfer.targetKeys" ) ,
155
+ } ) }
156
+ { props . children . sourceTitle . propertyView ( {
157
+ label : trans ( "transfer.sourceTitle" ) ,
158
+ } ) }
159
+ { props . children . targetTitle . propertyView ( {
160
+ label : trans ( "transfer.targetTitle" ) ,
161
+ } ) }
162
+ { props . children . showSearch . propertyView ( {
163
+ label : trans ( "transfer.allowSearch" ) ,
164
+ } ) }
165
+ { props . children . oneWay . propertyView ( {
166
+ label : trans ( "transfer.oneWay" ) ,
167
+ } ) }
168
+ { props . children . pagination . propertyView ( {
169
+ label : trans ( "transfer.pagination" ) ,
170
+ } ) }
171
+ { props . children . pagination . getView ( ) && props . children . pageSize . propertyView ( {
172
+ label : trans ( "transfer.pageSize" ) ,
173
+ } ) }
174
+ </ Section >
175
+ < Section name = { sectionNames . interaction } >
176
+ { props . children . onEvent . propertyView ( ) }
177
+ { hiddenPropertyView ( props . children ) }
178
+ { showDataLoadingIndicatorsPropertyView ( props . children ) }
179
+ </ Section >
180
+ < Section name = { sectionNames . style } > { props . children . style . getPropertyView ( ) } </ Section >
181
+ </ >
182
+ )
183
+ } ) ;
140
184
141
185
let TransferBasicComp = ( function ( ) {
142
186
return new UICompBuilder ( childrenMap , ( props , dispatch ) => {
143
187
return (
144
188
< TransferView { ...props } dispatch = { dispatch } /> ) } )
145
- . setPropertyViewFn ( ( children ) => (
146
- < >
147
- < Section name = { sectionNames . basic } >
148
- { children . items . propertyView ( {
149
- label : trans ( "transfer.items" ) ,
150
- } ) }
151
- { children . targetKeys . propertyView ( {
152
- label : trans ( "transfer.targetKeys" ) ,
153
- } ) }
154
- { children . sourceTitle . propertyView ( {
155
- label : trans ( "transfer.sourceTitle" ) ,
156
- } ) }
157
- { children . targetTitle . propertyView ( {
158
- label : trans ( "transfer.targetTitle" ) ,
159
- } ) }
160
- { children . showSearch . propertyView ( {
161
- label : trans ( "transfer.allowSearch" ) ,
162
- } ) }
163
- { children . oneWay . propertyView ( {
164
- label : trans ( "transfer.oneWay" ) ,
165
- } ) }
166
- { children . pagination . propertyView ( {
167
- label : trans ( "transfer.pagination" ) ,
168
- } ) }
169
- { children . pagination . getView ( ) && children . pageSize . propertyView ( {
170
- label : trans ( "transfer.pageSize" ) ,
171
- } ) }
172
- </ Section >
173
- < Section name = { sectionNames . interaction } >
174
- { children . onEvent . propertyView ( ) }
175
- { hiddenPropertyView ( children ) }
176
- { showDataLoadingIndicatorsPropertyView ( children ) }
177
- </ Section >
178
- < Section name = { sectionNames . style } > { children . style . getPropertyView ( ) } </ Section >
179
- </ >
180
- ) )
189
+ . setPropertyViewFn ( ( children ) => < TransferCompPropertyView children = { children } /> )
181
190
. build ( ) ;
182
191
} ) ( ) ;
183
192
0 commit comments