@@ -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,43 @@ 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
+ $fixedToolbar : boolean ;
148
+ } > `
149
+ display: flex;
150
+ flex-direction: column;
145
151
background: ${ ( props ) => props . $style . background } !important;
146
- // border: ${ ( props ) => `${ props . $style . border } !important` } ;
147
152
border-radius: ${ ( props ) => props . $style . radius } !important;
148
- // padding: unset !important;
149
153
padding: ${ ( props ) => props . $style . padding } !important;
150
154
margin: ${ ( props ) => props . $style . margin } !important;
151
- overflow: scroll !important;
152
155
border-style: ${ ( props ) => props . $style . borderStyle } !important;
153
156
border-width: ${ ( props ) => `${ props . $style . borderWidth } !important` } ;
154
- ${ ( props ) => props . $style }
157
+ border-color: ${ ( props ) => `${ props . $style . border } !important` } ;
158
+ height: calc(100% - ${ ( props ) => getVerticalMargin ( props . $style . margin . split ( ' ' ) ) } );
159
+ overflow: hidden;
160
+
161
+ > div.table-scrollbar-wrapper {
162
+ overflow: auto;
163
+ ${ ( props ) => props . $fixedToolbar && `height: auto` } ;
164
+
165
+ ${ ( props ) => ( props . $showHorizontalScrollbar || props . $showVerticalScrollbar ) && `
166
+ .simplebar-content-wrapper {
167
+ overflow: auto !important;
168
+ }
169
+ ` }
170
+
171
+ ${ ( props ) => ! props . $showHorizontalScrollbar && `
172
+ div.simplebar-horizontal {
173
+ visibility: hidden !important;
174
+ }
175
+ ` }
176
+ ${ ( props ) => ! props . $showVerticalScrollbar && `
177
+ div.simplebar-vertical {
178
+ visibility: hidden !important;
179
+ }
180
+ ` }
181
+ }
155
182
` ;
156
183
157
184
// TODO: find a way to limit the calc function for max-height only to first Margin value
@@ -166,8 +193,6 @@ const TableWrapper = styled.div<{
166
193
$visibleResizables : boolean ;
167
194
$showHRowGridBorder ?: boolean ;
168
195
} > `
169
- overflow: unset !important;
170
-
171
196
.ant-table-wrapper {
172
197
border-top: unset;
173
198
border-color: inherit;
@@ -193,22 +218,18 @@ const TableWrapper = styled.div<{
193
218
}
194
219
195
220
.ant-table {
196
- overflow-y:scroll;
197
221
background: ${ ( props ) => props . $style . background } ;
198
222
.ant-table-container {
199
223
border-left: unset;
200
224
border-top: none !important;
201
225
border-inline-start: none !important;
202
- overflow-y:scroll;
203
- height:300px
204
226
205
227
&::after {
206
228
box-shadow: none !important;
207
229
}
208
230
209
231
.ant-table-content {
210
- overflow-y:scroll;
211
- overflow-x:scroll;
232
+ overflow: unset !important
212
233
}
213
234
214
235
// A table expand row contains table
@@ -220,21 +241,23 @@ const TableWrapper = styled.div<{
220
241
border-top: unset;
221
242
222
243
> .ant-table-thead {
244
+ ${ ( props ) =>
245
+ props . $fixedHeader && `
246
+ position: sticky;
247
+ position: -webkit-sticky;
248
+ // top: ${ props . $fixedToolbar ? '47px' : '0' } ;
249
+ top: 0;
250
+ z-index: 99;
251
+ `
252
+ }
223
253
> tr > th {
224
254
background-color: ${ ( props ) => props . $headerStyle . headerBackground } ;
225
255
226
256
border-color: ${ ( props ) => props . $headerStyle . border } ;
227
257
border-width: ${ ( props ) => props . $headerStyle . borderWidth } ;
228
258
color: ${ ( props ) => props . $headerStyle . headerText } ;
229
259
// 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
- }
260
+
238
261
239
262
> div {
240
263
margin: ${ ( props ) => props . $headerStyle . margin } ;
@@ -715,6 +738,8 @@ export function TableCompView(props: {
715
738
const toolbarStyle = compChildren . toolbarStyle . getView ( ) ;
716
739
const rowAutoHeight = compChildren . rowAutoHeight . getView ( ) ;
717
740
const tableAutoHeight = comp . getTableAutoHeight ( ) ;
741
+ const showHorizontalScrollbar = compChildren . showHorizontalScrollbar . getView ( ) ;
742
+ const showVerticalScrollbar = compChildren . showVerticalScrollbar . getView ( ) ;
718
743
const visibleResizables = compChildren . visibleResizables . getView ( ) ;
719
744
const showHRowGridBorder = compChildren . showHRowGridBorder . getView ( ) ;
720
745
const columnsStyle = compChildren . columnsStyle . getView ( ) ;
@@ -830,72 +855,88 @@ export function TableCompView(props: {
830
855
return < EmptyContent text = { trans ( "table.emptyColumns" ) } /> ;
831
856
}
832
857
858
+ const hideScrollbar = ! showHorizontalScrollbar && ! showVerticalScrollbar ;
833
859
return (
834
860
< 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 }
861
+ < BackgroundWrapper
862
+ ref = { ref }
863
+ $style = { style }
864
+ $tableAutoHeight = { tableAutoHeight }
865
+ $showHorizontalScrollbar = { showHorizontalScrollbar }
866
+ $showVerticalScrollbar = { showVerticalScrollbar }
867
+ $fixedToolbar = { toolbar . fixedToolbar }
868
+ >
869
+ { toolbar . position === "above" && ( toolbar . fixedToolbar || ( tableAutoHeight && showHorizontalScrollbar ) ) && toolbarView }
870
+ < ScrollBar
871
+ className = "table-scrollbar-wrapper"
872
+ style = { { height : "100%" , margin : "0px" , padding : "0px" } }
873
+ hideScrollbar = { hideScrollbar }
874
+ prefixNode = { toolbar . position === "above" && ! toolbar . fixedToolbar && ! ( tableAutoHeight && showHorizontalScrollbar ) && toolbarView }
875
+ suffixNode = { toolbar . position === "below" && ! toolbar . fixedToolbar && ! ( tableAutoHeight && showHorizontalScrollbar ) && toolbarView }
847
876
>
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' )
877
+ < TableWrapper
878
+ $style = { style }
879
+ $rowStyle = { rowStyle }
880
+ $headerStyle = { headerStyle }
881
+ $toolbarStyle = { toolbarStyle }
882
+ $toolbarPosition = { toolbar . position }
883
+ $fixedHeader = { compChildren . fixedHeader . getView ( ) }
884
+ $fixedToolbar = { toolbar . fixedToolbar && toolbar . position === 'above' }
885
+ $visibleResizables = { visibleResizables }
886
+ $showHRowGridBorder = { showHRowGridBorder }
887
+ >
888
+ < ResizeableTable < RecordType >
889
+ expandable = { {
890
+ ...expansion . expandableConfig ,
891
+ childrenColumnName : supportChildren
892
+ ? COLUMN_CHILDREN_KEY
893
+ : "OB_CHILDREN_KEY_PLACEHOLDER" ,
894
+ fixed : "left" ,
895
+ onExpand : ( expanded ) => {
896
+ if ( expanded ) {
897
+ handleChangeEvent ( 'rowExpand' )
898
+ } else {
899
+ handleChangeEvent ( 'rowShrink' )
900
+ }
860
901
}
902
+ } }
903
+ rowColorFn = { compChildren . rowColor . getView ( ) as any }
904
+ rowHeightFn = { compChildren . rowHeight . getView ( ) as any }
905
+ { ...compChildren . selection . getView ( ) ( onEvent ) }
906
+ bordered = { compChildren . showRowGridBorder . getView ( ) }
907
+ onChange = { ( pagination , filters , sorter , extra ) => {
908
+ onTableChange ( pagination , filters , sorter , extra , comp . dispatch , onEvent ) ;
909
+ } }
910
+ showHeader = { ! compChildren . hideHeader . getView ( ) }
911
+ columns = { antdColumns }
912
+ columnsStyle = { columnsStyle }
913
+ viewModeResizable = { compChildren . viewModeResizable . getView ( ) }
914
+ visibleResizables = { compChildren . visibleResizables . getView ( ) }
915
+ dataSource = { pageDataInfo . data }
916
+ size = { compChildren . size . getView ( ) }
917
+ rowAutoHeight = { rowAutoHeight }
918
+ tableLayout = "fixed"
919
+ loading = {
920
+ loading ||
921
+ // fixme isLoading type
922
+ ( compChildren . showDataLoadSpinner . getView ( ) &&
923
+ ( compChildren . data as any ) . isLoading ( ) ) ||
924
+ compChildren . loading . getView ( )
861
925
}
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 }
926
+ onCellClick = { ( columnName : string , dataIndex : string ) => {
927
+ comp . children . selectedCell . dispatchChangeValueAction ( {
928
+ name : columnName ,
929
+ dataIndex : dataIndex ,
930
+ } ) ;
931
+ } }
932
+ />
933
+
934
+ < SlotConfigContext . Provider value = { { modalWidth : width && Math . max ( width , 300 ) } } >
935
+ { expansion . expandModalView }
936
+ </ SlotConfigContext . Provider >
937
+ </ TableWrapper >
938
+ </ ScrollBar >
939
+ { toolbar . position === "below" && ( toolbar . fixedToolbar || ( tableAutoHeight && showHorizontalScrollbar ) ) && toolbarView }
899
940
</ BackgroundWrapper >
900
941
901
942
</ BackgroundColorContext . Provider >
0 commit comments