@@ -28,7 +28,7 @@ import { BackgroundColorContext } from "comps/utils/backgroundColorContext";
2828import { PrimaryColor } from "constants/style" ;
2929import { trans } from "i18n" ;
3030import _ from "lodash" ;
31- import { darkenColor , isDarkColor } from "lowcoder-design" ;
31+ import { darkenColor , isDarkColor , ScrollBar } from "lowcoder-design" ;
3232import React , { Children , useCallback , useContext , useEffect , useMemo , useRef , useState } from "react" ;
3333import { Resizable } from "react-resizable" ;
3434import styled , { css } from "styled-components" ;
@@ -43,6 +43,7 @@ import { CellColorViewType } from "./column/tableColumnComp";
4343import { defaultTheme } from "@lowcoder-ee/constants/themeConstants" ;
4444import { useMergeCompStyles } from "@lowcoder-ee/util/hooks" ;
4545import { childrenToProps } from "@lowcoder-ee/comps/generators/multi" ;
46+ import { getVerticalMargin } from "@lowcoder-ee/util/cssUtil" ;
4647
4748
4849function genLinerGradient ( color : string ) {
@@ -141,17 +142,35 @@ const TitleResizeHandle = styled.span`
141142const BackgroundWrapper = styled . div < {
142143 $style : TableStyleType ;
143144 $tableAutoHeight : boolean ;
144- } > `
145+ $showHorizontalScrollbar : boolean ;
146+ $showVerticalScrollbar : boolean ;
147+ } > `
148+ display: flex;
149+ flex-direction: column;
145150 background: ${ ( props ) => props . $style . background } !important;
146- // border: ${ ( props ) => `${ props . $style . border } !important` } ;
147151 border-radius: ${ ( props ) => props . $style . radius } !important;
148- // padding: unset !important;
149152 padding: ${ ( props ) => props . $style . padding } !important;
150153 margin: ${ ( props ) => props . $style . margin } !important;
151- overflow: scroll !important;
152154 border-style: ${ ( props ) => props . $style . borderStyle } !important;
153155 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+ }
155174` ;
156175
157176// 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<{
166185 $visibleResizables : boolean ;
167186 $showHRowGridBorder ?: boolean ;
168187} > `
169- overflow: unset !important;
170-
171188 .ant-table-wrapper {
172189 border-top: unset;
173190 border-color: inherit;
@@ -193,22 +210,18 @@ const TableWrapper = styled.div<{
193210 }
194211
195212 .ant-table {
196- overflow-y:scroll;
197213 background: ${ ( props ) => props . $style . background } ;
198214 .ant-table-container {
199215 border-left: unset;
200216 border-top: none !important;
201217 border-inline-start: none !important;
202- overflow-y:scroll;
203- height:300px
204218
205219 &::after {
206220 box-shadow: none !important;
207221 }
208222
209223 .ant-table-content {
210- overflow-y:scroll;
211- overflow-x:scroll;
224+ overflow: unset !important
212225 }
213226
214227 // A table expand row contains table
@@ -220,21 +233,23 @@ const TableWrapper = styled.div<{
220233 border-top: unset;
221234
222235 > .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+ }
223245 > tr > th {
224246 background-color: ${ ( props ) => props . $headerStyle . headerBackground } ;
225247
226248 border-color: ${ ( props ) => props . $headerStyle . border } ;
227249 border-width: ${ ( props ) => props . $headerStyle . borderWidth } ;
228250 color: ${ ( props ) => props . $headerStyle . headerText } ;
229251 // 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+
238253
239254 > div {
240255 margin: ${ ( props ) => props . $headerStyle . margin } ;
@@ -715,6 +730,8 @@ export function TableCompView(props: {
715730 const toolbarStyle = compChildren . toolbarStyle . getView ( ) ;
716731 const rowAutoHeight = compChildren . rowAutoHeight . getView ( ) ;
717732 const tableAutoHeight = comp . getTableAutoHeight ( ) ;
733+ const showHorizontalScrollbar = compChildren . showHorizontalScrollbar . getView ( ) ;
734+ const showVerticalScrollbar = compChildren . showVerticalScrollbar . getView ( ) ;
718735 const visibleResizables = compChildren . visibleResizables . getView ( ) ;
719736 const showHRowGridBorder = compChildren . showHRowGridBorder . getView ( ) ;
720737 const columnsStyle = compChildren . columnsStyle . getView ( ) ;
@@ -832,70 +849,84 @@ export function TableCompView(props: {
832849
833850 return (
834851 < 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 }
847866 >
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+ }
860891 }
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 ( )
861915 }
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 }
899930 </ BackgroundWrapper >
900931
901932 </ BackgroundColorContext . Provider >
0 commit comments