1
- import { BoolControl } from "comps/controls/boolControl" ;
2
- import { ColorOrBoolCodeControl , NumberControl , RadiusControl , StringControl } from "comps/controls/codeControl" ;
3
- import { dropdownControl , HorizontalAlignmentControl } from "comps/controls/dropdownControl" ;
4
- import { MultiCompBuilder , stateComp , valueComp , withContext , withDefault } from "comps/generators" ;
1
+ import { RadiusControl , StringControl } from "comps/controls/codeControl" ;
2
+ import { HorizontalAlignmentControl } from "comps/controls/dropdownControl" ;
3
+ import { MultiCompBuilder , valueComp , withDefault } from "comps/generators" ;
5
4
import { withSelectedMultiContext } from "comps/generators/withSelectedMultiContext" ;
6
- import { genRandomKey } from "comps/utils/idGenerator" ;
7
5
import { trans } from "i18n" ;
8
6
import _ from "lodash" ;
9
7
import {
10
8
changeChildAction ,
11
- changeValueAction ,
12
9
CompAction ,
13
- CompActionTypes ,
14
10
ConstructorToComp ,
15
- ConstructorToDataType ,
16
- ConstructorToNodeType ,
17
- ConstructorToView ,
18
11
deferAction ,
19
12
fromRecord ,
20
- multiChangeAction ,
21
13
withFunction ,
22
14
wrapChildAction ,
23
15
} from "lowcoder-core" ;
24
- import { AlignClose , AlignLeft , AlignRight , IconRadius , BorderWidthIcon , TextSizeIcon , FontFamilyIcon , TextWeightIcon , ImageCompIcon , controlItem , Dropdown , OptionType } from "lowcoder-design" ;
25
- import { ColumnTypeComp , ColumnTypeCompMap } from "./columnTypeComp" ;
16
+ import { IconRadius , TextSizeIcon , FontFamilyIcon , TextWeightIcon , controlItem } from "lowcoder-design" ;
17
+ import { ColumnTypeComp } from "./columnTypeComp" ;
26
18
import { ColorControl } from "comps/controls/colorControl" ;
27
- import { JSONValue } from "util/jsonTypes" ;
28
19
import styled from "styled-components" ;
29
20
import { TextOverflowControl } from "comps/controls/textOverflowControl" ;
30
21
import { default as Divider } from "antd/es/divider" ;
31
- import { ColumnValueTooltip } from "./simpleColumnTypeComps" ;
32
22
export type Render = ReturnType < ConstructorToComp < typeof RenderComp > [ "getOriginalComp" ] > ;
33
23
export const RenderComp = withSelectedMultiContext ( ColumnTypeComp ) ;
34
24
35
- const columnWidthOptions = [
36
- {
37
- label : trans ( "table.auto" ) ,
38
- value : "auto" ,
39
- } ,
40
- {
41
- label : trans ( "table.fixed" ) ,
42
- value : "fixed" ,
43
- } ,
44
- ] as const ;
45
-
46
- const columnFixOptions = [
47
- {
48
- label : < AlignLeft /> ,
49
- value : "left" ,
50
- } ,
51
- {
52
- label : < AlignClose /> ,
53
- value : "close" ,
54
- } ,
55
- {
56
- label : < AlignRight /> ,
57
- value : "right" ,
58
- } ,
59
- ] as const ;
60
-
61
- const cellColorLabel = trans ( "table.cellColor" ) ;
62
- const CellColorTempComp = withContext (
63
- new MultiCompBuilder ( { color : ColorOrBoolCodeControl } , ( props ) => props . color )
64
- . setPropertyViewFn ( ( children ) =>
65
- children . color . propertyView ( {
66
- label : cellColorLabel ,
67
- tooltip : trans ( "table.cellColorDesc" ) ,
68
- } )
69
- )
70
- . build ( ) ,
71
- [ "currentCell" , "currentRow" ] as const
72
- ) ;
73
-
74
- // @ts -ignore
75
- export class CellColorComp extends CellColorTempComp {
76
- override getPropertyView ( ) {
77
- return controlItem ( { filterText : cellColorLabel } , super . getPropertyView ( ) ) ;
78
- }
79
- }
80
-
81
- // fixme, should be infer from RowColorComp, but withContext type incorrect
82
- export type CellColorViewType = ( param : {
83
- currentRow : any ;
84
- currentCell : JSONValue | undefined ; //number | string;
85
- } ) => string ;
86
-
87
- const cellTooltipLabel = trans ( "table.columnTooltip" ) ;
88
- const CellTooltipTempComp = withContext (
89
- new MultiCompBuilder ( { tooltip : StringControl } , ( props ) => props . tooltip )
90
- . setPropertyViewFn ( ( children ) =>
91
- children . tooltip . propertyView ( {
92
- label : cellTooltipLabel ,
93
- tooltip : ColumnValueTooltip ,
94
- } )
95
- )
96
- . build ( ) ,
97
- [ "currentCell" , "currentRow" , "currentIndex" ] as const
98
- ) ;
99
-
100
- // @ts -ignore
101
- export class CellTooltipComp extends CellTooltipTempComp {
102
- override getPropertyView ( ) {
103
- return controlItem ( { filterText : cellTooltipLabel } , super . getPropertyView ( ) ) ;
104
- }
105
- }
106
-
107
- // fixme, should be infer from RowColorComp, but withContext type incorrect
108
- export type CellTooltipViewType = ( param : {
109
- currentRow : any ;
110
- currentCell : JSONValue | undefined ; //number | string;
111
- } ) => string ;
112
-
113
-
114
25
export const columnChildrenMap = {
115
- cellTooltip : CellTooltipComp ,
26
+ cellTooltip : StringControl ,
116
27
// a custom column or a data column
117
28
isCustom : valueComp < boolean > ( false ) ,
118
29
// If it is a data column, it must be the name of the column and cannot be duplicated as a react key
119
30
dataIndex : valueComp < string > ( "" ) ,
120
- hide : BoolControl ,
121
31
render : RenderComp ,
122
32
align : HorizontalAlignmentControl ,
123
- fixed : dropdownControl ( columnFixOptions , "close" ) ,
124
33
background : withDefault ( ColorControl , "" ) ,
125
34
margin : withDefault ( RadiusControl , "" ) ,
126
35
text : withDefault ( ColorControl , "" ) ,
127
36
border : withDefault ( ColorControl , "" ) ,
128
- borderWidth : withDefault ( RadiusControl , "" ) ,
129
37
radius : withDefault ( RadiusControl , "" ) ,
130
38
textSize : withDefault ( RadiusControl , "" ) ,
131
39
textWeight : withDefault ( StringControl , "normal" ) ,
132
40
fontFamily : withDefault ( StringControl , "sans-serif" ) ,
133
41
fontStyle : withDefault ( StringControl , 'normal' ) ,
134
- cellColor : CellColorComp ,
42
+ cellColor : StringControl ,
135
43
textOverflow : withDefault ( TextOverflowControl , "ellipsis" ) ,
136
44
linkColor : withDefault ( ColorControl , "#3377ff" ) ,
137
45
linkHoverColor : withDefault ( ColorControl , "" ) ,
138
46
linkActiveColor : withDefault ( ColorControl , "" ) ,
139
47
} ;
140
48
141
49
const StyledBorderRadiusIcon = styled ( IconRadius ) ` width: 24px; margin: 0 8px 0 -3px; padding: 3px;` ;
142
- const StyledBorderIcon = styled ( BorderWidthIcon ) ` width: 24px; margin: 0 8px 0 -3px; padding: 3px;` ;
143
50
const StyledTextSizeIcon = styled ( TextSizeIcon ) ` width: 24px; margin: 0 8px 0 -3px; padding: 3px;` ;
144
51
const StyledFontFamilyIcon = styled ( FontFamilyIcon ) ` width: 24px; margin: 0 8px 0 -3px; padding: 3px;` ;
145
52
const StyledTextWeightIcon = styled ( TextWeightIcon ) ` width: 24px; margin: 0 8px 0 -3px; padding: 3px;` ;
146
- const StyledBackgroundImageIcon = styled ( ImageCompIcon ) ` width: 24px; margin: 0 0px 0 -12px;` ;
147
53
148
54
/**
149
55
* export for test.
@@ -159,28 +65,7 @@ const ColumnInitComp = new MultiCompBuilder(columnChildrenMap, (props, dispatch)
159
65
160
66
export class SummaryColumnComp extends ColumnInitComp {
161
67
override reduce ( action : CompAction ) {
162
- let comp = super . reduce ( action ) ;
163
- if ( action . type === CompActionTypes . UPDATE_NODES_V2 ) {
164
- comp = comp . setChild (
165
- "cellColor" ,
166
- comp . children . cellColor . reduce (
167
- CellColorComp . changeContextDataAction ( {
168
- currentCell : undefined ,
169
- currentRow : { } ,
170
- } )
171
- )
172
- ) ;
173
- comp = comp . setChild (
174
- "cellTooltip" ,
175
- comp . children . cellTooltip . reduce (
176
- CellTooltipComp . changeContextDataAction ( {
177
- currentCell : undefined ,
178
- currentRow : { } ,
179
- currentIndex : 0 ,
180
- } )
181
- )
182
- ) ;
183
- }
68
+ const comp = super . reduce ( action ) ;
184
69
return comp ;
185
70
}
186
71
@@ -218,20 +103,14 @@ export class SummaryColumnComp extends ColumnInitComp {
218
103
219
104
return (
220
105
< >
221
- { this . children . cellTooltip . getPropertyView ( ) }
222
- { /* FIXME: cast type currently, return type of withContext should be corrected later */ }
223
- { this . children . render . getPropertyView ( ) }
224
- { this . children . hide . propertyView ( {
225
- label : trans ( "prop.hide" ) ,
106
+ { this . children . cellTooltip . propertyView ( {
107
+ label : trans ( "table.columnTooltip" ) ,
226
108
} ) }
109
+ { this . children . render . getPropertyView ( ) }
227
110
{ this . children . align . propertyView ( {
228
111
label : trans ( "table.align" ) ,
229
112
radioButton : true ,
230
113
} ) }
231
- { this . children . fixed . propertyView ( {
232
- label : trans ( "table.fixedColumn" ) ,
233
- radioButton : true ,
234
- } ) }
235
114
{ ( columnType === 'link' || columnType === 'links' ) && (
236
115
< >
237
116
< Divider style = { { margin : '12px 0' } } />
@@ -266,11 +145,6 @@ export class SummaryColumnComp extends ColumnInitComp {
266
145
{ this . children . border . propertyView ( {
267
146
label : trans ( 'style.border' )
268
147
} ) }
269
- { this . children . borderWidth . propertyView ( {
270
- label : trans ( 'style.borderWidth' ) ,
271
- preInputNode : < StyledBorderIcon as = { BorderWidthIcon } title = "" /> ,
272
- placeholder : '1px' ,
273
- } ) }
274
148
{ this . children . radius . propertyView ( {
275
149
label : trans ( 'style.borderRadius' ) ,
276
150
preInputNode : < StyledBorderRadiusIcon as = { IconRadius } title = "" /> ,
@@ -296,8 +170,10 @@ export class SummaryColumnComp extends ColumnInitComp {
296
170
preInputNode : < StyledFontFamilyIcon as = { FontFamilyIcon } title = "" /> ,
297
171
placeholder : 'normal'
298
172
} ) }
299
- { this . children . textOverflow . getPropertyView ( ) }
300
- { this . children . cellColor . getPropertyView ( ) }
173
+ { /* {this.children.textOverflow.getPropertyView()} */ }
174
+ { this . children . cellColor . propertyView ( {
175
+ label : trans ( "table.cellColor" ) ,
176
+ } ) }
301
177
</ >
302
178
) ;
303
179
}
0 commit comments