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" ;
54import { withSelectedMultiContext } from "comps/generators/withSelectedMultiContext" ;
6- import { genRandomKey } from "comps/utils/idGenerator" ;
75import { trans } from "i18n" ;
86import _ from "lodash" ;
97import {
108 changeChildAction ,
11- changeValueAction ,
129 CompAction ,
13- CompActionTypes ,
1410 ConstructorToComp ,
15- ConstructorToDataType ,
16- ConstructorToNodeType ,
17- ConstructorToView ,
1811 deferAction ,
1912 fromRecord ,
20- multiChangeAction ,
2113 withFunction ,
2214 wrapChildAction ,
2315} 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" ;
2618import { ColorControl } from "comps/controls/colorControl" ;
27- import { JSONValue } from "util/jsonTypes" ;
2819import styled from "styled-components" ;
2920import { TextOverflowControl } from "comps/controls/textOverflowControl" ;
3021import { default as Divider } from "antd/es/divider" ;
31- import { ColumnValueTooltip } from "./simpleColumnTypeComps" ;
3222export type Render = ReturnType < ConstructorToComp < typeof RenderComp > [ "getOriginalComp" ] > ;
3323export const RenderComp = withSelectedMultiContext ( ColumnTypeComp ) ;
3424
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-
11425export const columnChildrenMap = {
115- cellTooltip : CellTooltipComp ,
26+ cellTooltip : StringControl ,
11627 // a custom column or a data column
11728 isCustom : valueComp < boolean > ( false ) ,
11829 // If it is a data column, it must be the name of the column and cannot be duplicated as a react key
11930 dataIndex : valueComp < string > ( "" ) ,
120- hide : BoolControl ,
12131 render : RenderComp ,
12232 align : HorizontalAlignmentControl ,
123- fixed : dropdownControl ( columnFixOptions , "close" ) ,
12433 background : withDefault ( ColorControl , "" ) ,
12534 margin : withDefault ( RadiusControl , "" ) ,
12635 text : withDefault ( ColorControl , "" ) ,
12736 border : withDefault ( ColorControl , "" ) ,
128- borderWidth : withDefault ( RadiusControl , "" ) ,
12937 radius : withDefault ( RadiusControl , "" ) ,
13038 textSize : withDefault ( RadiusControl , "" ) ,
13139 textWeight : withDefault ( StringControl , "normal" ) ,
13240 fontFamily : withDefault ( StringControl , "sans-serif" ) ,
13341 fontStyle : withDefault ( StringControl , 'normal' ) ,
134- cellColor : CellColorComp ,
42+ cellColor : StringControl ,
13543 textOverflow : withDefault ( TextOverflowControl , "ellipsis" ) ,
13644 linkColor : withDefault ( ColorControl , "#3377ff" ) ,
13745 linkHoverColor : withDefault ( ColorControl , "" ) ,
13846 linkActiveColor : withDefault ( ColorControl , "" ) ,
13947} ;
14048
14149const 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;` ;
14350const StyledTextSizeIcon = styled ( TextSizeIcon ) ` width: 24px; margin: 0 8px 0 -3px; padding: 3px;` ;
14451const StyledFontFamilyIcon = styled ( FontFamilyIcon ) ` width: 24px; margin: 0 8px 0 -3px; padding: 3px;` ;
14552const StyledTextWeightIcon = styled ( TextWeightIcon ) ` width: 24px; margin: 0 8px 0 -3px; padding: 3px;` ;
146- const StyledBackgroundImageIcon = styled ( ImageCompIcon ) ` width: 24px; margin: 0 0px 0 -12px;` ;
14753
14854/**
14955 * export for test.
@@ -159,28 +65,7 @@ const ColumnInitComp = new MultiCompBuilder(columnChildrenMap, (props, dispatch)
15965
16066export class SummaryColumnComp extends ColumnInitComp {
16167 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 ) ;
18469 return comp ;
18570 }
18671
@@ -218,20 +103,14 @@ export class SummaryColumnComp extends ColumnInitComp {
218103
219104 return (
220105 < >
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" ) ,
226108 } ) }
109+ { this . children . render . getPropertyView ( ) }
227110 { this . children . align . propertyView ( {
228111 label : trans ( "table.align" ) ,
229112 radioButton : true ,
230113 } ) }
231- { this . children . fixed . propertyView ( {
232- label : trans ( "table.fixedColumn" ) ,
233- radioButton : true ,
234- } ) }
235114 { ( columnType === 'link' || columnType === 'links' ) && (
236115 < >
237116 < Divider style = { { margin : '12px 0' } } />
@@ -266,11 +145,6 @@ export class SummaryColumnComp extends ColumnInitComp {
266145 { this . children . border . propertyView ( {
267146 label : trans ( 'style.border' )
268147 } ) }
269- { this . children . borderWidth . propertyView ( {
270- label : trans ( 'style.borderWidth' ) ,
271- preInputNode : < StyledBorderIcon as = { BorderWidthIcon } title = "" /> ,
272- placeholder : '1px' ,
273- } ) }
274148 { this . children . radius . propertyView ( {
275149 label : trans ( 'style.borderRadius' ) ,
276150 preInputNode : < StyledBorderRadiusIcon as = { IconRadius } title = "" /> ,
@@ -296,8 +170,10 @@ export class SummaryColumnComp extends ColumnInitComp {
296170 preInputNode : < StyledFontFamilyIcon as = { FontFamilyIcon } title = "" /> ,
297171 placeholder : 'normal'
298172 } ) }
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+ } ) }
301177 </ >
302178 ) ;
303179 }
0 commit comments