@@ -21,6 +21,7 @@ import {
21
21
TableHeaderStyleType ,
22
22
TableRowStyleType ,
23
23
TableStyleType ,
24
+ ThemeDetail ,
24
25
TableToolbarStyleType ,
25
26
} from "comps/controls/styleControlConstants" ;
26
27
import { CompNameContext , EditorContext } from "comps/editorState" ;
@@ -29,7 +30,7 @@ import { PrimaryColor } from "constants/style";
29
30
import { trans } from "i18n" ;
30
31
import _ from "lodash" ;
31
32
import { darkenColor , isDarkColor } from "lowcoder-design" ;
32
- import React , { useCallback , useContext , useEffect , useMemo , useRef , useState } from "react" ;
33
+ import React , { Children , useCallback , useContext , useEffect , useMemo , useRef , useState } from "react" ;
33
34
import { Resizable } from "react-resizable" ;
34
35
import styled , { css } from "styled-components" ;
35
36
import { useUserViewMode } from "util/hooks" ;
@@ -41,15 +42,6 @@ import { messageInstance } from "lowcoder-design";
41
42
import { ReactRef , ResizeHandleAxis } from "layout/gridLayoutPropTypes" ;
42
43
import { CellColorViewType } from "./column/tableColumnComp" ;
43
44
44
- const TitleResizeHandle = styled . span `
45
- position : absolute;
46
- top : 0 ;
47
- right : -5px ;
48
- width : 10px ;
49
- height : 100% ;
50
- cursor : col-resize;
51
- z-index : 1 ;
52
- ` ;
53
45
54
46
function genLinerGradient ( color : string ) {
55
47
return `linear-gradient(${ color } , ${ color } )` ;
@@ -65,10 +57,11 @@ const getStyle = (
65
57
const selectedRowBackground = genLinerGradient ( rowStyle . selectedRowBackground ) ;
66
58
const hoverRowBackground = genLinerGradient ( rowStyle . hoverRowBackground ) ;
67
59
const alternateBackground = genLinerGradient ( rowStyle . alternateBackground ) ;
60
+ // const tableAutoHeight =
68
61
69
62
return css `
70
63
.ant-table-body {
71
- background : white ;
64
+ background: ${ genLinerGradient ( style . background ) } ;
72
65
}
73
66
.ant-table-tbody {
74
67
> tr:nth-of-type(2n + 1) {
@@ -130,6 +123,32 @@ const getStyle = (
130
123
` ;
131
124
} ;
132
125
126
+ const TitleResizeHandle = styled . span `
127
+ position: absolute;
128
+ top: 0;
129
+ right: -5px;
130
+ width: 10px;
131
+ height: 100%;
132
+ cursor: col-resize;
133
+ z-index: 1;
134
+ ` ;
135
+
136
+ const BackgroundWrapper = styled . div < {
137
+ $style : TableStyleType ;
138
+ $tableAutoHeight ?: boolean ;
139
+ } > `
140
+ ${ ( props ) => ! props . $tableAutoHeight && ` height: calc(100% - ${ props . $style . margin } - ${ props . $style . margin } ) !important` } ;
141
+ ${ ( props ) => props . $tableAutoHeight && ` height: calc(100% + ${ props . $style . margin } ` } ;
142
+ background: ${ ( props ) => props . $style . background } !important;
143
+ border: ${ ( props ) => `${ props . $style . borderWidth } solid ${ props . $style . border } !important` } ;
144
+ border-radius: ${ ( props ) => props . $style . radius } !important;
145
+ padding: unset !important;
146
+ margin: ${ ( props ) => props . $style . margin } !important;
147
+ overflow: scroll !important;
148
+ ${ ( props ) => props . $style }
149
+ ` ;
150
+
151
+ // TODO: find a way to limit the calc function for max-height only to first Margin value
133
152
const TableWrapper = styled . div < {
134
153
$style : TableStyleType ;
135
154
$headerStyle : TableHeaderStyleType ;
@@ -139,16 +158,10 @@ const TableWrapper = styled.div<{
139
158
$fixedHeader : boolean ;
140
159
$fixedToolbar : boolean ;
141
160
} > `
142
- max-height: 100%;
143
- overflow-y: auto;
144
- background: ${ ( props ) => props . $style . background } ;
145
- border: ${ ( props ) => `${ props . $style . borderWidth } solid ${ props . $style . border } ` } ;
146
- border-radius: ${ ( props ) => props . $style . radius } ;
147
- padding: ${ ( props ) => props . $style . padding } ;
148
- margin: ${ ( props ) => props . $style . margin } ;
161
+ overflow: unset !important;
149
162
150
163
.ant-table-wrapper {
151
- border-top: ${ ( props ) => ( props . $toolbarPosition === "above" ? "1px solid" : " unset" ) } ;
164
+ border-top: unset;
152
165
border-color: inherit;
153
166
}
154
167
@@ -299,6 +312,7 @@ const TableTh = styled.th<{ width?: number }>`
299
312
const TableTd = styled . td < {
300
313
$background : string ;
301
314
$style : TableColumnStyleType & { rowHeight ?: string } ;
315
+ $defaultThemeDetail : ThemeDetail ;
302
316
$linkStyle ?: TableColumnLinkStyleType ;
303
317
$isEditing : boolean ;
304
318
$tableSize ?: string ;
@@ -316,40 +330,42 @@ const TableTd = styled.td<{
316
330
border-color: ${ ( props ) => props . $style . border } !important;
317
331
border-width: ${ ( props ) => props . $style . borderWidth } !important;
318
332
border-radius: ${ ( props ) => props . $style . radius } ;
319
- margin: ${ ( props ) => props . $style . margin } ;
320
333
321
334
padding: 0 !important;
322
335
323
336
> div {
337
+ margin: ${ ( props ) => props . $style . margin } ;
324
338
color: ${ ( props ) => props . $style . text } ;
325
- font-size: ${ ( props ) => props . $style . textSize } ;
326
- line-height: 21px;
327
-
339
+
328
340
${ ( props ) => props . $tableSize === 'small' && `
329
- padding: 8.5px 8px;
330
- min-height: ${ props . $style . rowHeight || '39px' } ;
341
+ padding: 1px 8px;
342
+ font-size: ${ props . $defaultThemeDetail . textSize == props . $style . textSize ? '14px !important' : props . $style . textSize + ' !important' } ;
343
+ min-height: ${ props . $style . rowHeight || '14px' } ;
344
+ line-height: 20px;
331
345
${ ! props . $autoHeight && `
332
346
overflow-y: auto;
333
- max-height: ${ props . $style . rowHeight || '39px ' } ;
347
+ max-height: ${ props . $style . rowHeight || '28px ' } ;
334
348
` } ;
335
349
` } ;
336
350
${ ( props ) => props . $tableSize === 'middle' && `
337
- padding: 12.5px 8px;
338
- min-height: ${ props . $style . rowHeight || '47px' } ;
351
+ padding: 8px 8px;
352
+ font-size: ${ props . $defaultThemeDetail . textSize == props . $style . textSize ? '16px !important' : props . $style . textSize + ' !important' } ;
353
+ min-height: ${ props . $style . rowHeight || '24px' } ;
354
+ line-height: 24px;
339
355
${ ! props . $autoHeight && `
340
356
overflow-y: auto;
341
- max-height: ${ props . $style . rowHeight || '47px ' } ;
357
+ max-height: ${ props . $style . rowHeight || '48px ' } ;
342
358
` } ;
343
359
` } ;
344
360
${ ( props ) => props . $tableSize === 'large' && `
345
- padding: 16.5px 16px;
346
- min-height: ${ props . $style . rowHeight || '55px' } ;
361
+ padding: 16px 16px;
362
+ font-size: ${ props . $defaultThemeDetail . textSize == props . $style . textSize ? '18px !important' : props . $style . textSize + ' !important' } ;
363
+ min-height: ${ props . $style . rowHeight || '48px' } ;
347
364
${ ! props . $autoHeight && `
348
365
overflow-y: auto;
349
- max-height: ${ props . $style . rowHeight || '55px ' } ;
366
+ max-height: ${ props . $style . rowHeight || '96px ' } ;
350
367
` } ;
351
368
` } ;
352
-
353
369
354
370
> div > .ant-badge > .ant-badge-status-text,
355
371
> div > div > .markdown-body {
@@ -516,6 +532,7 @@ function TableCellView(props: {
516
532
{ ...restProps }
517
533
$background = { background }
518
534
$style = { style }
535
+ $defaultThemeDetail = { defaultTheme }
519
536
$linkStyle = { linkStyle }
520
537
$isEditing = { editing }
521
538
$tableSize = { tableSize }
@@ -656,6 +673,7 @@ export function TableCompView(props: {
656
673
const [ loading , setLoading ] = useState ( false ) ;
657
674
const { comp, onDownload, onRefresh } = props ;
658
675
const compChildren = comp . children ;
676
+ const tableAutoHeight = compChildren . autoHeight . getView ( ) ;
659
677
const style = compChildren . style . getView ( ) ;
660
678
const rowStyle = compChildren . rowStyle . getView ( ) ;
661
679
const headerStyle = compChildren . headerStyle . getView ( ) ;
@@ -768,57 +786,64 @@ export function TableCompView(props: {
768
786
769
787
return (
770
788
< BackgroundColorContext . Provider value = { style . background } >
771
- < div ref = { ref } style = { { height : '100%' } } >
772
- < TableWrapper
773
- $style = { style }
774
- $rowStyle = { rowStyle }
775
- $headerStyle = { headerStyle }
776
- $toolbarStyle = { toolbarStyle }
777
- $toolbarPosition = { toolbar . position }
778
- $fixedHeader = { compChildren . fixedHeader . getView ( ) }
779
- $fixedToolbar = { toolbar . fixedToolbar && toolbar . position === 'above' }
789
+
790
+ < BackgroundWrapper ref = { ref } $style = { style }
791
+ $tableAutoHeight = { compChildren . autoHeight . getView ( ) }
780
792
>
781
793
{ toolbar . position === "above" && toolbarView }
782
- < ResizeableTable < RecordType >
783
- expandable = { {
784
- ...expansion . expandableConfig ,
785
- childrenColumnName : supportChildren
786
- ? COLUMN_CHILDREN_KEY
787
- : "OB_CHILDREN_KEY_PLACEHOLDER" ,
788
- fixed : "left" ,
789
- onExpand : ( expanded ) => {
790
- if ( expanded ) handleChangeEvent ( 'rowExpand' )
794
+ < TableWrapper
795
+ $style = { style }
796
+ $rowStyle = { rowStyle }
797
+ $headerStyle = { headerStyle }
798
+ $toolbarStyle = { toolbarStyle }
799
+ $toolbarPosition = { toolbar . position }
800
+ $fixedHeader = { compChildren . fixedHeader . getView ( ) }
801
+ $fixedToolbar = { toolbar . fixedToolbar && toolbar . position === 'above' }
802
+ >
803
+
804
+
805
+ < ResizeableTable < RecordType >
806
+ expandable = { {
807
+ ...expansion . expandableConfig ,
808
+ childrenColumnName : supportChildren
809
+ ? COLUMN_CHILDREN_KEY
810
+ : "OB_CHILDREN_KEY_PLACEHOLDER" ,
811
+ fixed : "left" ,
812
+ onExpand : ( expanded ) => {
813
+ if ( expanded ) handleChangeEvent ( 'rowExpand' )
814
+ }
815
+ } }
816
+ rowColorFn = { compChildren . rowColor . getView ( ) as any }
817
+ rowHeightFn = { compChildren . rowHeight . getView ( ) as any }
818
+ { ...compChildren . selection . getView ( ) ( onEvent ) }
819
+ bordered = { compChildren . showHeaderGridBorder . getView ( ) }
820
+ onChange = { ( pagination , filters , sorter , extra ) => {
821
+ onTableChange ( pagination , filters , sorter , extra , comp . dispatch , onEvent ) ;
822
+ } }
823
+ showHeader = { ! compChildren . hideHeader . getView ( ) }
824
+ columns = { antdColumns }
825
+ columnsStyle = { columnsStyle }
826
+ viewModeResizable = { compChildren . viewModeResizable . getView ( ) }
827
+ dataSource = { pageDataInfo . data }
828
+ size = { compChildren . size . getView ( ) }
829
+ rowAutoHeight = { rowAutoHeight }
830
+ tableLayout = "fixed"
831
+ loading = {
832
+ loading ||
833
+ // fixme isLoading type
834
+ ( compChildren . showDataLoadSpinner . getView ( ) &&
835
+ ( compChildren . data as any ) . isLoading ( ) ) ||
836
+ compChildren . loading . getView ( )
791
837
}
792
- } }
793
- rowColorFn = { compChildren . rowColor . getView ( ) as any }
794
- rowHeightFn = { compChildren . rowHeight . getView ( ) as any }
795
- { ...compChildren . selection . getView ( ) ( onEvent ) }
796
- bordered = { ! compChildren . hideBordered . getView ( ) }
797
- onChange = { ( pagination , filters , sorter , extra ) => {
798
- onTableChange ( pagination , filters , sorter , extra , comp . dispatch , onEvent ) ;
799
- } }
800
- showHeader = { ! compChildren . hideHeader . getView ( ) }
801
- columns = { antdColumns }
802
- columnsStyle = { columnsStyle }
803
- viewModeResizable = { compChildren . viewModeResizable . getView ( ) }
804
- dataSource = { pageDataInfo . data }
805
- size = { compChildren . size . getView ( ) }
806
- rowAutoHeight = { rowAutoHeight }
807
- tableLayout = "fixed"
808
- loading = {
809
- loading ||
810
- // fixme isLoading type
811
- ( compChildren . showDataLoadSpinner . getView ( ) &&
812
- ( compChildren . data as any ) . isLoading ( ) ) ||
813
- compChildren . loading . getView ( )
814
- }
815
- />
838
+ />
839
+
840
+ < SlotConfigContext . Provider value = { { modalWidth : width && Math . max ( width , 300 ) } } >
841
+ { expansion . expandModalView }
842
+ </ SlotConfigContext . Provider >
843
+ </ TableWrapper >
816
844
{ toolbar . position === "below" && toolbarView }
817
- < SlotConfigContext . Provider value = { { modalWidth : width && Math . max ( width , 300 ) } } >
818
- { expansion . expandModalView }
819
- </ SlotConfigContext . Provider >
820
- </ TableWrapper >
821
- </ div >
845
+ </ BackgroundWrapper >
846
+
822
847
</ BackgroundColorContext . Provider >
823
848
) ;
824
849
}
0 commit comments