1
1
import { CompAction , RecordConstructorToView , changeChildAction } from "lowcoder-core" ;
2
2
import { styleControl } from "comps/controls/styleControl" ;
3
- import { QRCodeStyle , QRCodeStyleType , avatarGroupStyle , AvatarGroupStyleType , avatarContainerStyle , AvatarContainerStyleType } from "comps/controls/styleControlConstants" ;
3
+ import { avatarGroupStyle , avatarContainerStyle , AvatarContainerStyleType } from "comps/controls/styleControlConstants" ;
4
4
import { UICompBuilder } from "comps/generators/uiCompBuilder" ;
5
5
import { NameConfig , NameConfigHidden , withExposingConfigs } from "comps/generators/withExposing" ;
6
- import { AlignCenter , AlignLeft , AlignRight , Section , sectionNames } from "lowcoder-design" ;
7
- import { hiddenPropertyView } from "comps/utils/propertyUtils" ;
6
+ import { AlignCenter , AlignLeft , AlignRight } from "lowcoder-design" ;
8
7
import { trans } from "i18n" ;
9
8
import { NumberControl , StringControl } from "comps/controls/codeControl" ;
10
9
import { Avatar , Tooltip } from "antd" ;
11
10
import { clickEvent , eventHandlerControl , refreshEvent } from "../controls/eventHandlerControl" ;
12
11
import styled from "styled-components" ;
13
- import { useContext , ReactElement , useEffect } from "react" ;
12
+ import React , { ReactElement } from "react" ;
14
13
import { MultiCompBuilder , stateComp , withDefault } from "../generators" ;
15
- import { EditorContext } from "comps/editorState" ;
16
14
import { IconControl } from "../controls/iconControl" ;
17
15
import { ColorControl } from "../controls/colorControl" ;
18
16
import { optionsControl } from "../controls/optionsControl" ;
19
17
import { BoolControl } from "../controls/boolControl" ;
20
18
import { dropdownControl } from "../controls/dropdownControl" ;
21
19
import { JSONObject } from "util/jsonTypes" ;
22
20
import { MultiIconDisplay } from "@lowcoder-ee/comps/comps/multiIconDisplay" ;
23
-
21
+ import { viewMode } from "@lowcoder-ee/util/editor" ;
22
+ const SetPropertyViewAvatarGroup1 = React . lazy ( async ( ) => await import ( "./setProperty/avatarGroup" ) . then ( module => ( { default : module . SetPropertyViewAvatarGroup1 } ) ) )
23
+ const SetPropertyViewAvatarGroup2 = React . lazy ( async ( ) => await import ( "./setProperty/avatarGroup" ) . then ( module => ( { default : module . SetPropertyViewAvatarGroup2 } ) ) )
24
24
const MacaroneList = [
25
25
'#fde68a' ,
26
26
'#eecff3' ,
@@ -48,7 +48,7 @@ const Container = styled.div<{ $style: AvatarContainerStyleType | undefined, ali
48
48
border-width: ${ props => props ?. $style ?. borderWidth } ;
49
49
` ;
50
50
51
- const DropdownOption = new MultiCompBuilder (
51
+ let DropdownOption = new MultiCompBuilder (
52
52
{
53
53
src : StringControl ,
54
54
AvatarIcon : IconControl ,
@@ -59,24 +59,10 @@ const DropdownOption = new MultiCompBuilder(
59
59
} ,
60
60
( props ) => props
61
61
)
62
- . setPropertyViewFn ( ( children ) => (
63
- < >
64
- { children . src . propertyView ( { label : trans ( "avatarComp.src" ) , placeholder : "" , tooltip : trans ( "avatarComp.avatarCompTooltip" ) } ) }
65
- { children . label . propertyView ( {
66
- label : trans ( "avatarComp.title" ) ,
67
- tooltip : trans ( "avatarComp.avatarCompTooltip" ) ,
68
- } ) }
69
- { children . AvatarIcon . propertyView ( {
70
- label : trans ( "avatarComp.icon" ) ,
71
- IconType : "All" ,
72
- tooltip : trans ( "avatarComp.avatarCompTooltip" ) ,
73
- } ) }
74
- { children . color . propertyView ( { label : trans ( "style.fill" ) } ) }
75
- { children . backgroundColor . propertyView ( { label : trans ( "style.background" ) } ) }
76
- { children . Tooltip . propertyView ( { label : trans ( "badge.tooltip" ) } ) }
77
- </ >
78
- ) )
79
- . build ( ) ;
62
+ if ( viewMode ( ) === "edit" ) {
63
+ DropdownOption . setPropertyViewFn ( ( children ) => < SetPropertyViewAvatarGroup1 { ...children } > </ SetPropertyViewAvatarGroup1 > ) ;
64
+ }
65
+ const DropdownOptionBuilder = DropdownOption . build ( ) ;
80
66
81
67
const EventOptions = [ clickEvent , refreshEvent ] as const ;
82
68
@@ -95,7 +81,7 @@ const childrenMap = {
95
81
autoColor : BoolControl . DEFAULT_TRUE ,
96
82
onEvent : eventHandlerControl ( EventOptions ) ,
97
83
currentAvatar : stateComp < JSONObject > ( { } ) ,
98
- avatars : optionsControl ( DropdownOption , {
84
+ avatars : optionsControl ( DropdownOptionBuilder , {
99
85
initOptions : [
100
86
{ src : "https://api.dicebear.com/7.x/miniavs/svg?seed=1" , label : String . fromCharCode ( 65 + Math . ceil ( Math . random ( ) * 25 ) ) } ,
101
87
{ AvatarIcon : "/icon:antd/startwotone" } ,
@@ -143,48 +129,13 @@ const AvatarGroupView = (props: RecordConstructorToView<typeof childrenMap> & {
143
129
} ;
144
130
145
131
let AvatarGroupBasicComp = ( function ( ) {
146
- return new UICompBuilder ( childrenMap , ( props , dispatch ) => {
132
+ let builder = new UICompBuilder ( childrenMap , ( props , dispatch ) => {
147
133
return ( < AvatarGroupView { ...props } dispatch = { dispatch } />
148
- ) } )
149
- . setPropertyViewFn ( ( children ) => (
150
- < >
151
- { [ "logic" , "both" ] . includes ( useContext ( EditorContext ) . editorModeStatus ) && (
152
- < >
153
- < Section name = { sectionNames . basic } >
154
- { children . avatars . propertyView ( { } ) }
155
- { children . maxCount . propertyView ( {
156
- label : trans ( "avatarGroup.maxCount" )
157
- } ) }
158
- { children . avatarSize . propertyView ( {
159
- label : trans ( "avatarGroup.avatarSize" )
160
- } ) }
161
- { children . autoColor . propertyView ( {
162
- label : trans ( "avatarGroup.autoColor" )
163
- } ) }
164
- { children . alignment . propertyView ( {
165
- label : trans ( "avatarGroup.alignment" ) ,
166
- radioButton : true ,
167
- } ) }
168
- </ Section >
169
- < Section name = { sectionNames . interaction } >
170
- { hiddenPropertyView ( children ) }
171
- { children . onEvent . propertyView ( ) }
172
- </ Section >
173
- </ >
174
- ) }
175
-
176
- { [ "layout" , "both" ] . includes ( useContext ( EditorContext ) . editorModeStatus ) && (
177
- < >
178
- < Section name = { sectionNames . avatarStyle } >
179
- { children . avatar . getPropertyView ( ) }
180
- </ Section >
181
- < Section name = { sectionNames . style } >
182
- { children . style . getPropertyView ( ) }
183
- </ Section >
184
- </ >
185
- ) }
186
- </ >
187
- ) )
134
+ ) } )
135
+ if ( viewMode ( ) === "edit" ) {
136
+ builder . setPropertyViewFn ( ( children ) => < SetPropertyViewAvatarGroup2 { ...children } > </ SetPropertyViewAvatarGroup2 > ) ;
137
+ }
138
+ return builder
188
139
. build ( ) ;
189
140
} ) ( ) ;
190
141
0 commit comments