11import { BoolControl } from "comps/controls/boolControl" ;
2- import { NumberControl , StringControl } from "comps/controls/codeControl" ;
2+ import { ColorOrBoolCodeControl , NumberControl , RadiusControl , StringControl } from "comps/controls/codeControl" ;
33import { dropdownControl , HorizontalAlignmentControl } from "comps/controls/dropdownControl" ;
4- import { MultiCompBuilder , stateComp , valueComp } from "comps/generators" ;
4+ import { MultiCompBuilder , stateComp , valueComp , withContext , withDefault } from "comps/generators" ;
55import { withSelectedMultiContext } from "comps/generators/withSelectedMultiContext" ;
66import { genRandomKey } from "comps/utils/idGenerator" ;
77import { trans } from "i18n" ;
88import _ from "lodash" ;
99import {
1010 changeChildAction ,
1111 changeValueAction ,
12+ CompAction ,
13+ CompActionTypes ,
1214 ConstructorToComp ,
1315 ConstructorToDataType ,
1416 ConstructorToNodeType ,
@@ -19,8 +21,10 @@ import {
1921 withFunction ,
2022 wrapChildAction ,
2123} from "lowcoder-core" ;
22- import { AlignClose , AlignLeft , AlignRight } from "lowcoder-design" ;
24+ import { AlignClose , AlignLeft , AlignRight , controlItem } from "lowcoder-design" ;
2325import { ColumnTypeComp , ColumnTypeCompMap } from "./columnTypeComp" ;
26+ import { ColorControl } from "comps/controls/colorControl" ;
27+ import { JSONValue } from "util/jsonTypes" ;
2428
2529export type Render = ReturnType < ConstructorToComp < typeof RenderComp > [ "getOriginalComp" ] > ;
2630export const RenderComp = withSelectedMultiContext ( ColumnTypeComp ) ;
@@ -51,6 +55,31 @@ const columnFixOptions = [
5155 } ,
5256] as const ;
5357
58+ const cellColorLabel = trans ( "table.cellColor" ) ;
59+ const CellColorTempComp = withContext (
60+ new MultiCompBuilder ( { color : ColorOrBoolCodeControl } , ( props ) => props . color )
61+ . setPropertyViewFn ( ( children ) =>
62+ children . color . propertyView ( {
63+ label : cellColorLabel ,
64+ tooltip : trans ( "table.cellColorDesc" ) ,
65+ } )
66+ )
67+ . build ( ) ,
68+ [ "currentCell" ] as const
69+ ) ;
70+
71+ // @ts -ignore
72+ export class CellColorComp extends CellColorTempComp {
73+ override getPropertyView ( ) {
74+ return controlItem ( { filterText : cellColorLabel } , super . getPropertyView ( ) ) ;
75+ }
76+ }
77+
78+ // fixme, should be infer from RowColorComp, but withContext type incorrect
79+ export type CellColorViewType = ( param : {
80+ currentCell : JSONValue | undefined ; //number | string;
81+ } ) => string ;
82+
5483export const columnChildrenMap = {
5584 // column title
5685 title : StringControl ,
@@ -67,6 +96,11 @@ export const columnChildrenMap = {
6796 tempHide : stateComp < boolean > ( false ) ,
6897 fixed : dropdownControl ( columnFixOptions , "close" ) ,
6998 editable : BoolControl ,
99+ background : withDefault ( ColorControl , "" ) ,
100+ text : withDefault ( ColorControl , "" ) ,
101+ border : withDefault ( ColorControl , "" ) ,
102+ radius : withDefault ( RadiusControl , "" ) ,
103+ cellColor : CellColorComp ,
70104} ;
71105
72106/**
@@ -90,6 +124,21 @@ const ColumnInitComp = new MultiCompBuilder(columnChildrenMap, (props, dispatch)
90124 . build ( ) ;
91125
92126export class ColumnComp extends ColumnInitComp {
127+ override reduce ( action : CompAction ) {
128+ let comp = super . reduce ( action ) ;
129+ if ( action . type === CompActionTypes . UPDATE_NODES_V2 ) {
130+ comp = comp . setChild (
131+ "cellColor" ,
132+ comp . children . cellColor . reduce (
133+ CellColorComp . changeContextDataAction ( {
134+ currentCell : undefined ,
135+ } )
136+ )
137+ ) ;
138+ }
139+ return comp ;
140+ }
141+
93142 override getView ( ) {
94143 const superView = super . getView ( ) ;
95144 const columnType = this . children . render . getSelectedComp ( ) . getComp ( ) . children . compType . getView ( ) ;
@@ -143,6 +192,26 @@ export class ColumnComp extends ColumnInitComp {
143192 } ) }
144193 { this . children . autoWidth . getView ( ) === "fixed" &&
145194 this . children . width . propertyView ( { label : trans ( "prop.width" ) } ) }
195+ { controlItem ( { } , (
196+ < div style = { { marginTop : '8px' } } >
197+ < b > { "Style" } </ b >
198+ </ div >
199+ ) ) }
200+ { this . children . background . propertyView ( {
201+ label : trans ( 'style.background' ) ,
202+ } ) }
203+ { this . children . text . propertyView ( {
204+ label : trans ( 'text' ) ,
205+ } ) }
206+ { this . children . border . propertyView ( {
207+ label : trans ( 'style.border' )
208+ } ) }
209+ { this . children . radius . propertyView ( {
210+ label : trans ( 'style.borderRadius' ) ,
211+ // preInputNode: <StyledIcon as={IconRadius} title="" />,
212+ placeholder : '3px' ,
213+ } ) }
214+ { this . children . cellColor . getPropertyView ( ) }
146215 </ >
147216 ) ;
148217 }
0 commit comments