@@ -28,7 +28,7 @@ import { BackgroundColorContext } from "comps/utils/backgroundColorContext";
28
28
import { PrimaryColor } from "constants/style" ;
29
29
import { trans } from "i18n" ;
30
30
import _ from "lodash" ;
31
- import { darkenColor , isDarkColor } from "lowcoder-design" ;
31
+ import { darkenColor , isDarkColor , ScrollBar } from "lowcoder-design" ;
32
32
import React , { Children , useCallback , useContext , useEffect , useMemo , useRef , useState } from "react" ;
33
33
import { Resizable } from "react-resizable" ;
34
34
import styled , { css } from "styled-components" ;
@@ -43,6 +43,7 @@ import { CellColorViewType } from "./column/tableColumnComp";
43
43
import { defaultTheme } from "@lowcoder-ee/constants/themeConstants" ;
44
44
import { useMergeCompStyles } from "@lowcoder-ee/util/hooks" ;
45
45
import { childrenToProps } from "@lowcoder-ee/comps/generators/multi" ;
46
+ import { getVerticalMargin } from "@lowcoder-ee/util/cssUtil" ;
46
47
47
48
48
49
function genLinerGradient ( color : string ) {
@@ -141,17 +142,35 @@ const TitleResizeHandle = styled.span`
141
142
const BackgroundWrapper = styled . div < {
142
143
$style : TableStyleType ;
143
144
$tableAutoHeight : boolean ;
144
- } > `
145
+ $showHorizontalScrollbar : boolean ;
146
+ $showVerticalScrollbar : boolean ;
147
+ } > `
148
+ display: flex;
149
+ flex-direction: column;
145
150
background: ${ ( props ) => props . $style . background } !important;
146
- // border: ${ ( props ) => `${ props . $style . border } !important` } ;
147
151
border-radius: ${ ( props ) => props . $style . radius } !important;
148
- // padding: unset !important;
149
152
padding: ${ ( props ) => props . $style . padding } !important;
150
153
margin: ${ ( props ) => props . $style . margin } !important;
151
- overflow: scroll !important;
152
154
border-style: ${ ( props ) => props . $style . borderStyle } !important;
153
155
border-width: ${ ( props ) => `${ props . $style . borderWidth } !important` } ;
154
- ${ ( props ) => props . $style }
156
+ border-color: ${ ( props ) => `${ props . $style . border } !important` } ;
157
+ height: calc(100% - ${ ( props ) => getVerticalMargin ( props . $style . margin . split ( ' ' ) ) } );
158
+ overflow: hidden;
159
+
160
+ > div.table-scrollbar-wrapper {
161
+ height: auto;
162
+ overflow: auto;
163
+ ${ ( props ) => ! props . $showHorizontalScrollbar && `
164
+ div.simplebar-horizontal {
165
+ visibility: hidden !important;
166
+ }
167
+ ` }
168
+ ${ ( props ) => ! props . $showVerticalScrollbar && `
169
+ div.simplebar-vertical {
170
+ visibility: hidden !important;
171
+ }
172
+ ` }
173
+ }
155
174
` ;
156
175
157
176
// TODO: find a way to limit the calc function for max-height only to first Margin value
@@ -166,8 +185,6 @@ const TableWrapper = styled.div<{
166
185
$visibleResizables : boolean ;
167
186
$showHRowGridBorder ?: boolean ;
168
187
} > `
169
- overflow: unset !important;
170
-
171
188
.ant-table-wrapper {
172
189
border-top: unset;
173
190
border-color: inherit;
@@ -193,22 +210,18 @@ const TableWrapper = styled.div<{
193
210
}
194
211
195
212
.ant-table {
196
- overflow-y:scroll;
197
213
background: ${ ( props ) => props . $style . background } ;
198
214
.ant-table-container {
199
215
border-left: unset;
200
216
border-top: none !important;
201
217
border-inline-start: none !important;
202
- overflow-y:scroll;
203
- height:300px
204
218
205
219
&::after {
206
220
box-shadow: none !important;
207
221
}
208
222
209
223
.ant-table-content {
210
- overflow-y:scroll;
211
- overflow-x:scroll;
224
+ overflow: unset !important
212
225
}
213
226
214
227
// A table expand row contains table
@@ -220,21 +233,23 @@ const TableWrapper = styled.div<{
220
233
border-top: unset;
221
234
222
235
> .ant-table-thead {
236
+ ${ ( props ) =>
237
+ props . $fixedHeader && `
238
+ position: sticky;
239
+ position: -webkit-sticky;
240
+ // top: ${ props . $fixedToolbar ? '47px' : '0' } ;
241
+ top: 0;
242
+ z-index: 99;
243
+ `
244
+ }
223
245
> tr > th {
224
246
background-color: ${ ( props ) => props . $headerStyle . headerBackground } ;
225
247
226
248
border-color: ${ ( props ) => props . $headerStyle . border } ;
227
249
border-width: ${ ( props ) => props . $headerStyle . borderWidth } ;
228
250
color: ${ ( props ) => props . $headerStyle . headerText } ;
229
251
// border-inline-end: ${ ( props ) => `${ props . $headerStyle . borderWidth } solid ${ props . $headerStyle . border } ` } !important;
230
- ${ ( props ) =>
231
- props . $fixedHeader && `
232
- position: sticky;
233
- position: -webkit-sticky;
234
- top: ${ props . $fixedToolbar ? '47px' : '0' } ;
235
- z-index: 99;
236
- `
237
- }
252
+
238
253
239
254
> div {
240
255
margin: ${ ( props ) => props . $headerStyle . margin } ;
@@ -715,6 +730,8 @@ export function TableCompView(props: {
715
730
const toolbarStyle = compChildren . toolbarStyle . getView ( ) ;
716
731
const rowAutoHeight = compChildren . rowAutoHeight . getView ( ) ;
717
732
const tableAutoHeight = comp . getTableAutoHeight ( ) ;
733
+ const showHorizontalScrollbar = compChildren . showHorizontalScrollbar . getView ( ) ;
734
+ const showVerticalScrollbar = compChildren . showVerticalScrollbar . getView ( ) ;
718
735
const visibleResizables = compChildren . visibleResizables . getView ( ) ;
719
736
const showHRowGridBorder = compChildren . showHRowGridBorder . getView ( ) ;
720
737
const columnsStyle = compChildren . columnsStyle . getView ( ) ;
@@ -832,70 +849,84 @@ export function TableCompView(props: {
832
849
833
850
return (
834
851
< BackgroundColorContext . Provider value = { style . background } >
835
- < BackgroundWrapper ref = { ref } $style = { style } $tableAutoHeight = { tableAutoHeight } >
836
- { toolbar . position === "above" && toolbarView }
837
- < TableWrapper
838
- $style = { style }
839
- $rowStyle = { rowStyle }
840
- $headerStyle = { headerStyle }
841
- $toolbarStyle = { toolbarStyle }
842
- $toolbarPosition = { toolbar . position }
843
- $fixedHeader = { compChildren . fixedHeader . getView ( ) }
844
- $fixedToolbar = { toolbar . fixedToolbar && toolbar . position === 'above' }
845
- $visibleResizables = { visibleResizables }
846
- $showHRowGridBorder = { showHRowGridBorder }
852
+ < BackgroundWrapper
853
+ ref = { ref }
854
+ $style = { style }
855
+ $tableAutoHeight = { tableAutoHeight }
856
+ $showHorizontalScrollbar = { showHorizontalScrollbar }
857
+ $showVerticalScrollbar = { showVerticalScrollbar }
858
+ >
859
+ { toolbar . position === "above" && toolbar . fixedToolbar && toolbarView }
860
+ < ScrollBar
861
+ className = "table-scrollbar-wrapper"
862
+ style = { { height : "100%" , margin : "0px" , padding : "0px" } }
863
+ hideScrollbar = { ! showHorizontalScrollbar && ! showVerticalScrollbar }
864
+ prefixNode = { toolbar . position === "above" && ! toolbar . fixedToolbar && toolbarView }
865
+ suffixNode = { toolbar . position === "below" && ! toolbar . fixedToolbar && toolbarView }
847
866
>
848
- < ResizeableTable < RecordType >
849
- expandable = { {
850
- ...expansion . expandableConfig ,
851
- childrenColumnName : supportChildren
852
- ? COLUMN_CHILDREN_KEY
853
- : "OB_CHILDREN_KEY_PLACEHOLDER" ,
854
- fixed : "left" ,
855
- onExpand : ( expanded ) => {
856
- if ( expanded ) {
857
- handleChangeEvent ( 'rowExpand' )
858
- } else {
859
- handleChangeEvent ( 'rowShrink' )
867
+ < TableWrapper
868
+ $style = { style }
869
+ $rowStyle = { rowStyle }
870
+ $headerStyle = { headerStyle }
871
+ $toolbarStyle = { toolbarStyle }
872
+ $toolbarPosition = { toolbar . position }
873
+ $fixedHeader = { compChildren . fixedHeader . getView ( ) }
874
+ $fixedToolbar = { toolbar . fixedToolbar && toolbar . position === 'above' }
875
+ $visibleResizables = { visibleResizables }
876
+ $showHRowGridBorder = { showHRowGridBorder }
877
+ >
878
+ < ResizeableTable < RecordType >
879
+ expandable = { {
880
+ ...expansion . expandableConfig ,
881
+ childrenColumnName : supportChildren
882
+ ? COLUMN_CHILDREN_KEY
883
+ : "OB_CHILDREN_KEY_PLACEHOLDER" ,
884
+ fixed : "left" ,
885
+ onExpand : ( expanded ) => {
886
+ if ( expanded ) {
887
+ handleChangeEvent ( 'rowExpand' )
888
+ } else {
889
+ handleChangeEvent ( 'rowShrink' )
890
+ }
860
891
}
892
+ } }
893
+ rowColorFn = { compChildren . rowColor . getView ( ) as any }
894
+ rowHeightFn = { compChildren . rowHeight . getView ( ) as any }
895
+ { ...compChildren . selection . getView ( ) ( onEvent ) }
896
+ bordered = { compChildren . showRowGridBorder . getView ( ) }
897
+ onChange = { ( pagination , filters , sorter , extra ) => {
898
+ onTableChange ( pagination , filters , sorter , extra , comp . dispatch , onEvent ) ;
899
+ } }
900
+ showHeader = { ! compChildren . hideHeader . getView ( ) }
901
+ columns = { antdColumns }
902
+ columnsStyle = { columnsStyle }
903
+ viewModeResizable = { compChildren . viewModeResizable . getView ( ) }
904
+ visibleResizables = { compChildren . visibleResizables . getView ( ) }
905
+ dataSource = { pageDataInfo . data }
906
+ size = { compChildren . size . getView ( ) }
907
+ rowAutoHeight = { rowAutoHeight }
908
+ tableLayout = "fixed"
909
+ loading = {
910
+ loading ||
911
+ // fixme isLoading type
912
+ ( compChildren . showDataLoadSpinner . getView ( ) &&
913
+ ( compChildren . data as any ) . isLoading ( ) ) ||
914
+ compChildren . loading . getView ( )
861
915
}
862
- } }
863
- rowColorFn = { compChildren . rowColor . getView ( ) as any }
864
- rowHeightFn = { compChildren . rowHeight . getView ( ) as any }
865
- { ...compChildren . selection . getView ( ) ( onEvent ) }
866
- bordered = { compChildren . showRowGridBorder . getView ( ) }
867
- onChange = { ( pagination , filters , sorter , extra ) => {
868
- onTableChange ( pagination , filters , sorter , extra , comp . dispatch , onEvent ) ;
869
- } }
870
- showHeader = { ! compChildren . hideHeader . getView ( ) }
871
- columns = { antdColumns }
872
- columnsStyle = { columnsStyle }
873
- viewModeResizable = { compChildren . viewModeResizable . getView ( ) }
874
- visibleResizables = { compChildren . visibleResizables . getView ( ) }
875
- dataSource = { pageDataInfo . data }
876
- size = { compChildren . size . getView ( ) }
877
- rowAutoHeight = { rowAutoHeight }
878
- tableLayout = "fixed"
879
- loading = {
880
- loading ||
881
- // fixme isLoading type
882
- ( compChildren . showDataLoadSpinner . getView ( ) &&
883
- ( compChildren . data as any ) . isLoading ( ) ) ||
884
- compChildren . loading . getView ( )
885
- }
886
- onCellClick = { ( columnName : string , dataIndex : string ) => {
887
- comp . children . selectedCell . dispatchChangeValueAction ( {
888
- name : columnName ,
889
- dataIndex : dataIndex ,
890
- } ) ;
891
- } }
892
- />
893
-
894
- < SlotConfigContext . Provider value = { { modalWidth : width && Math . max ( width , 300 ) } } >
895
- { expansion . expandModalView }
896
- </ SlotConfigContext . Provider >
897
- </ TableWrapper >
898
- { toolbar . position === "below" && toolbarView }
916
+ onCellClick = { ( columnName : string , dataIndex : string ) => {
917
+ comp . children . selectedCell . dispatchChangeValueAction ( {
918
+ name : columnName ,
919
+ dataIndex : dataIndex ,
920
+ } ) ;
921
+ } }
922
+ />
923
+
924
+ < SlotConfigContext . Provider value = { { modalWidth : width && Math . max ( width , 300 ) } } >
925
+ { expansion . expandModalView }
926
+ </ SlotConfigContext . Provider >
927
+ </ TableWrapper >
928
+ </ ScrollBar >
929
+ { toolbar . position === "below" && toolbar . fixedToolbar && toolbarView }
899
930
</ BackgroundWrapper >
900
931
901
932
</ BackgroundColorContext . Provider >
0 commit comments