1
- import ReactResizeDetector from 'react-resize-detector' ;
1
+ import ReactResizeDetector from "react-resize-detector" ;
2
+ import { NameConfigHidden , withExposingConfigs } from "comps/generators/withExposing" ;
3
+ import { Section , sectionNames } from "lowcoder-design" ;
4
+ import { TriContainer } from "../triContainerComp/triContainer" ;
2
5
import {
3
- NameConfigHidden ,
4
- withExposingConfigs ,
5
- } from 'comps/generators/withExposing' ;
6
- import { Section , sectionNames } from 'lowcoder-design' ;
7
- import { TriContainer } from '../triContainerComp/triContainer' ;
8
- import { ContainerCompBuilder } from '../triContainerComp/triContainerCompBuilder' ;
9
- import {
10
- disabledPropertyView ,
11
- hiddenPropertyView ,
12
- } from 'comps/utils/propertyUtils' ;
13
- import { trans } from 'i18n' ;
14
- import { BoolCodeControl , StringControl } from 'comps/controls/codeControl' ;
15
- import { BoolControl } from 'comps/controls/boolControl' ;
16
- import { useContext , useEffect , useRef , useState } from 'react' ;
17
- import { EditorContext } from 'comps/editorState' ;
18
- import { Card } from 'antd' ;
19
- import styled from 'styled-components' ;
20
- import {
21
- AnimationStyle ,
22
- AnimationStyleType ,
23
- CardHeaderStyle ,
24
- CardHeaderStyleType ,
25
- CardStyle ,
26
- CardStyleType ,
27
- } from 'comps/controls/styleControlConstants' ;
28
- import { MultiCompBuilder , withDefault } from 'comps/generators' ;
29
- import { IconControl } from 'comps/controls/iconControl' ;
30
- import {
31
- ButtonEventHandlerControl ,
32
- CardEventHandlerControl ,
33
- clickEvent ,
34
- refreshEvent ,
35
- } from 'comps/controls/eventHandlerControl' ;
36
- import { optionsControl } from 'comps/controls/optionsControl' ;
37
- import { dropdownControl } from 'comps/controls/dropdownControl' ;
38
- import { styleControl } from 'comps/controls/styleControl' ;
39
- const { Meta} = Card ;
6
+ ContainerCompBuilder ,
7
+ } from "../triContainerComp/triContainerCompBuilder" ;
8
+ import { disabledPropertyView , hiddenPropertyView } from "comps/utils/propertyUtils" ;
9
+ import { trans } from "i18n" ;
10
+ import { BoolCodeControl , StringControl } from "comps/controls/codeControl" ;
11
+ import { BoolControl } from "comps/controls/boolControl" ;
12
+ import { useContext , useEffect , useRef , useState } from "react" ;
13
+ import { EditorContext } from "comps/editorState" ;
14
+ import { Card } from "antd" ;
15
+ import styled from "styled-components" ;
16
+ import { AnimationStyle , AnimationStyleType , CardHeaderStyle , CardHeaderStyleType , CardStyle , CardStyleType } from "comps/controls/styleControlConstants" ;
17
+ import { MultiCompBuilder , withDefault } from "comps/generators" ;
18
+ import { IconControl } from "comps/controls/iconControl" ;
19
+ import { ButtonEventHandlerControl , CardEventHandlerControl , clickEvent , refreshEvent } from "comps/controls/eventHandlerControl" ;
20
+ import { optionsControl } from "comps/controls/optionsControl" ;
21
+ import { dropdownControl } from "comps/controls/dropdownControl" ;
22
+ import { styleControl } from "comps/controls/styleControl" ;
23
+ const { Meta } = Card ;
40
24
41
25
const Warpper = styled . div < {
42
26
$style : CardStyleType | undefined ;
43
27
$showMate : boolean ;
44
28
$cardType : string ;
45
29
$headerStyle : CardHeaderStyleType ;
46
30
$bodyStyle : CardHeaderStyleType ;
47
- $animationStyle : AnimationStyleType ;
31
+ $animationStyle :AnimationStyleType ;
48
32
} > `
49
33
height: 100%;
50
34
width: 100%;
@@ -93,7 +77,7 @@ const Warpper = styled.div<{
93
77
border-style: ${ ( props ) => props . $style ?. borderStyle } ;
94
78
border-radius: ${ ( props ) => props . $style ?. radius } ;
95
79
border-width: ${ ( props ) => props . $style ?. borderWidth } ;
96
- ${ ( props ) => props . $animationStyle }
80
+ ${ props => props . $animationStyle }
97
81
}
98
82
.ant-card-body {
99
83
display: ${ ( props ) => ( props . $showMate ? '' : 'none' ) } ;
@@ -122,39 +106,36 @@ const Warpper = styled.div<{
122
106
const ContainWarpper = styled . div `
123
107
height: 100%;
124
108
width: 100%;
125
- ` ;
109
+ `
126
110
127
- const IconWarpper = styled . div < {
128
- $style : CardStyleType | undefined ;
129
- disabled : boolean ;
130
- } > `
131
- pointer-events: ${ ( props ) => ( props . disabled ? 'none' : '' ) } ;
111
+ const IconWarpper = styled . div < { $style : CardStyleType | undefined , disabled : boolean } > `
112
+ pointer-events: ${ props => props . disabled ? 'none' : '' } ;
132
113
svg {
133
- color: ${ ( props ) => ( props . disabled ? '#d9d9d9' : props . $style ?. IconColor ) } ;
114
+ color: ${ props => props . disabled ? '#d9d9d9' : props . $style ?. IconColor } ;
134
115
}
135
116
&:hover {
136
117
svg {
137
- color: ${ ( props ) => props . $style ?. activateColor } ;
118
+ color: ${ props => props . $style ?. activateColor } ;
138
119
}
139
- }
140
- ` ;
120
+ }
121
+ `
141
122
142
123
const cardTypeOption = [
143
- { label : trans ( ' card.common' ) , value : ' common' } ,
144
- { label : trans ( ' card.custom' ) , value : ' custom' } ,
124
+ { label : trans ( " card.common" ) , value : " common" } ,
125
+ { label : trans ( " card.custom" ) , value : " custom" } ,
145
126
] as const ;
146
127
147
128
const sizeOptions = [
148
- { label : trans ( ' card.default' ) , value : ' default' } ,
149
- { label : trans ( ' card.small' ) , value : ' small' } ,
129
+ { label : trans ( " card.default" ) , value : " default" } ,
130
+ { label : trans ( " card.small" ) , value : " small" } ,
150
131
] as const ;
151
132
152
133
const EventOptions = [ clickEvent , refreshEvent ] as const ;
153
134
154
135
const ActionIconOption = new MultiCompBuilder (
155
136
{
156
137
label : StringControl ,
157
- icon : withDefault ( IconControl , ' /icon:antd/settingoutlined' ) ,
138
+ icon : withDefault ( IconControl , " /icon:antd/settingoutlined" ) ,
158
139
disabled : BoolCodeControl ,
159
140
hidden : BoolCodeControl ,
160
141
onEvent : ButtonEventHandlerControl ,
@@ -163,7 +144,7 @@ const ActionIconOption = new MultiCompBuilder(
163
144
)
164
145
. setPropertyViewFn ( ( children ) => (
165
146
< >
166
- { children . icon . propertyView ( { label : trans ( ' button.icon' ) } ) }
147
+ { children . icon . propertyView ( { label : trans ( " button.icon" ) } ) }
167
148
{ disabledPropertyView ( children ) }
168
149
{ hiddenPropertyView ( children ) }
169
150
{ children . onEvent . getPropertyView ( ) }
@@ -173,18 +154,9 @@ const ActionIconOption = new MultiCompBuilder(
173
154
174
155
const ActionOptionControl = optionsControl ( ActionIconOption , {
175
156
initOptions : [
176
- {
177
- label : trans ( 'optionsControl.optionI' , { i : 1 } ) ,
178
- icon : '/icon:antd/settingoutlined' ,
179
- } ,
180
- {
181
- label : trans ( 'optionsControl.optionI' , { i : 2 } ) ,
182
- icon : '/icon:antd/editoutlined' ,
183
- } ,
184
- {
185
- label : trans ( 'optionsControl.optionI' , { i : 3 } ) ,
186
- icon : '/icon:antd/ellipsisoutlined' ,
187
- } ,
157
+ { label : trans ( "optionsControl.optionI" , { i : 1 } ) , icon : "/icon:antd/settingoutlined" } ,
158
+ { label : trans ( "optionsControl.optionI" , { i : 2 } ) , icon : "/icon:antd/editoutlined" } ,
159
+ { label : trans ( "optionsControl.optionI" , { i : 3 } ) , icon : "/icon:antd/ellipsisoutlined" } ,
188
160
] ,
189
161
} ) ;
190
162
@@ -222,7 +194,7 @@ export const ContainerBaseComp = (function () {
222
194
CONTAINER_BODY_PADDING : props . style . containerBodyPadding ,
223
195
border : '#00000000' ,
224
196
background : props . style . background ,
225
- } ) ;
197
+ } )
226
198
const conRef = useRef < HTMLDivElement > ( null ) ;
227
199
const [ width , setWidth ] = useState ( 0 ) ;
228
200
const [ height , setHeight ] = useState ( 0 ) ;
@@ -251,54 +223,34 @@ export const ContainerBaseComp = (function () {
251
223
onMouseLeave = { ( ) => props . onEvent ( 'blur' ) }
252
224
onClick = { ( ) => props . onEvent ( 'click' ) }
253
225
>
254
- {
255
- < Card
256
- style = { { width : width , height : '100%' } }
257
- size = { props . size }
258
- hoverable = { props . hoverable }
259
- // 标题设置
260
- title = { props . showTitle && props . title }
261
- extra = {
262
- props . showTitle && (
263
- < a href = "#" onClick = { ( ) => props . onEvent ( 'clickExtra' ) } >
264
- { props . extraTitle }
265
- </ a >
266
- )
267
- }
268
- // 内容
269
- cover = {
270
- props . cardType == 'common' &&
271
- props . CoverImg && (
272
- < img src = { props . imgSrc } height = { props . imgHeight } />
273
- )
274
- }
275
- actions = {
276
- props . cardType == 'common' && props . showActionIcon
277
- ? props . actionOptions
278
- . filter ( ( item ) => ! item . hidden )
279
- . map ( ( item ) => {
280
- return (
281
- < IconWarpper
282
- onClick = { ( ) => item . onEvent ( 'click' ) }
283
- disabled = { item . disabled }
284
- $style = { props . style }
285
- >
286
- { item . icon }
287
- </ IconWarpper >
288
- ) ;
289
- } )
290
- : [ ]
226
+ { < Card
227
+ style = { { width : width , height : '100%' } }
228
+ size = { props . size }
229
+ hoverable = { props . hoverable }
230
+ // 标题设置
231
+ title = { props . showTitle && props . title }
232
+ extra = { props . showTitle && < a href = "#" onClick = { ( ) => props . onEvent ( 'clickExtra' ) } > { props . extraTitle } </ a > }
233
+
234
+ // 内容
235
+ cover = { props . cardType == 'common' && props . CoverImg && < img src = { props . imgSrc } height = { props . imgHeight } /> }
236
+ actions = { props . cardType == 'common' && props . showActionIcon ?
237
+ props . actionOptions . filter ( item => ! item . hidden ) . map ( item => {
238
+ return (
239
+ < IconWarpper
240
+ onClick = { ( ) => item . onEvent ( 'click' ) }
241
+ disabled = { item . disabled }
242
+ $style = { props . style }
243
+ >
244
+ { item . icon }
245
+ </ IconWarpper > )
291
246
}
292
- >
293
- { props . cardType == 'common' && props . showMeta && (
294
- < Meta title = { props . metaTitle } description = { props . metaDesc } />
295
- ) }
296
- { props . cardType == 'custom' && (
297
- < ContainWarpper >
298
- < TriContainer { ...props } />
299
- </ ContainWarpper >
300
- ) }
301
- </ Card >
247
+ ) : [ ]
248
+ }
249
+ >
250
+ { props . cardType == 'common' && props . showMeta && < Meta title = { props . metaTitle } description = { props . metaDesc } /> }
251
+ { props . cardType == 'custom' && < ContainWarpper >
252
+ < TriContainer { ...props } /> </ ContainWarpper > }
253
+ </ Card >
302
254
}
303
255
</ Warpper >
304
256
</ ReactResizeDetector >
@@ -307,60 +259,56 @@ export const ContainerBaseComp = (function () {
307
259
. setPropertyViewFn ( ( children ) => {
308
260
return (
309
261
< >
310
- { ( useContext ( EditorContext ) . editorModeStatus === 'logic' ||
311
- useContext ( EditorContext ) . editorModeStatus === 'both' ) && (
262
+ { ( useContext ( EditorContext ) . editorModeStatus === "logic" || useContext ( EditorContext ) . editorModeStatus === "both" ) && (
312
263
< >
313
264
< Section name = { sectionNames . basic } >
314
265
{ children . size . propertyView ( {
315
- label : trans ( ' card.titleSize' ) ,
266
+ label : trans ( " card.titleSize" ) ,
316
267
radioButton : true ,
317
268
} ) }
318
- { children . showTitle . propertyView ( {
319
- label : trans ( 'card.showTitle' ) ,
320
- } ) }
321
- { children . showTitle . getView ( ) &&
322
- children . title . propertyView ( { label : trans ( 'card.title' ) } ) }
323
- { children . showTitle . getView ( ) &&
324
- children . extraTitle . propertyView ( {
325
- label : trans ( 'card.extraTitle' ) ,
326
- } ) }
327
- { children . cardType . getView ( ) == 'common' &&
328
- children . CoverImg . propertyView ( {
329
- label : trans ( 'card.CoverImg' ) ,
330
- } ) }
269
+ { children . showTitle . propertyView ( { label : trans ( 'card.showTitle' ) } ) }
270
+ { children . showTitle . getView ( ) && children . title . propertyView ( { label : trans ( 'card.title' ) } ) }
271
+ { children . showTitle . getView ( ) && children . extraTitle . propertyView ( { label : trans ( 'card.extraTitle' ) } ) }
272
+ {
273
+ children . cardType . getView ( ) == 'common' &&
274
+ children . CoverImg . propertyView ( { label : trans ( 'card.CoverImg' ) } )
275
+ }
331
276
332
- { children . cardType . getView ( ) == 'common' &&
277
+ {
278
+ children . cardType . getView ( ) == 'common' &&
333
279
children . CoverImg . getView ( ) &&
334
- children . imgSrc . propertyView ( { label : trans ( 'card.imgSrc' ) } ) }
335
- { children . cardType . getView ( ) == 'common' &&
280
+ children . imgSrc . propertyView ( { label : trans ( 'card.imgSrc' ) } )
281
+ }
282
+ {
283
+ children . cardType . getView ( ) == 'common' &&
336
284
children . CoverImg . getView ( ) &&
337
- children . imgHeight . propertyView ( {
338
- label : trans ( 'card.imgHeight' ) ,
339
- } ) }
340
- { children . cardType . getView ( ) == 'common' &&
341
- children . showMeta . propertyView ( {
342
- label : trans ( 'card.showMeta' ) ,
343
- } ) }
344
- { children . cardType . getView ( ) == 'common' &&
285
+ children . imgHeight . propertyView ( { label : trans ( 'card.imgHeight' ) } )
286
+ }
287
+ {
288
+ children . cardType . getView ( ) == 'common' &&
289
+ children . showMeta . propertyView ( { label : trans ( 'card.showMeta' ) } )
290
+ }
291
+ {
292
+ children . cardType . getView ( ) == 'common' &&
345
293
children . showMeta . getView ( ) &&
346
- children . metaTitle . propertyView ( {
347
- label : trans ( 'card.metaTitle' ) ,
348
- } ) }
349
- { children . cardType . getView ( ) == 'common' &&
294
+ children . metaTitle . propertyView ( { label : trans ( 'card.metaTitle' ) } )
295
+ }
296
+ {
297
+ children . cardType . getView ( ) == 'common' &&
350
298
children . showMeta . getView ( ) &&
351
- children . metaDesc . propertyView ( {
352
- label : trans ( 'card.metaDesc' ) ,
353
- } ) }
299
+ children . metaDesc . propertyView ( { label : trans ( 'card.metaDesc' ) } )
300
+ }
354
301
355
- { children . cardType . getView ( ) == 'common' &&
356
- children . showActionIcon . propertyView ( {
357
- label : trans ( 'card.showActionIcon' ) ,
358
- } ) }
359
- { children . cardType . getView ( ) == 'common' &&
302
+ {
303
+ children . cardType . getView ( ) == 'common' &&
304
+ children . showActionIcon . propertyView ( { label : trans ( 'card.showActionIcon' ) } )
305
+ }
306
+ {
307
+ children . cardType . getView ( ) == 'common' &&
360
308
children . showActionIcon . getView ( ) &&
361
- children . actionOptions . propertyView ( {
362
- title : trans ( 'card.actionOptions' ) ,
363
- } ) }
309
+ children . actionOptions . propertyView ( { title : trans ( 'card.actionOptions' ) } )
310
+ }
311
+
364
312
</ Section >
365
313
< Section name = { sectionNames . interaction } >
366
314
{ hiddenPropertyView ( children ) }
@@ -369,12 +317,11 @@ export const ContainerBaseComp = (function () {
369
317
</ >
370
318
) }
371
319
372
- { ( useContext ( EditorContext ) . editorModeStatus === 'layout' ||
373
- useContext ( EditorContext ) . editorModeStatus === 'both' ) && (
320
+ { ( useContext ( EditorContext ) . editorModeStatus === "layout" || useContext ( EditorContext ) . editorModeStatus === "both" ) && (
374
321
< >
375
322
< Section name = { sectionNames . layout } >
376
323
{ children . cardType . propertyView ( {
377
- label : trans ( ' card.cardType' ) ,
324
+ label : trans ( " card.cardType" ) ,
378
325
radioButton : true ,
379
326
} ) }
380
327
</ Section >
@@ -398,6 +345,5 @@ export const ContainerBaseComp = (function () {
398
345
. build ( ) ;
399
346
} ) ( ) ;
400
347
401
- export const CardComp = withExposingConfigs ( ContainerBaseComp , [
402
- NameConfigHidden ,
403
- ] ) ;
348
+ export const CardComp = withExposingConfigs ( ContainerBaseComp , [ NameConfigHidden ] ) ;
349
+
0 commit comments