@@ -21,6 +21,7 @@ import {
2121 TableHeaderStyleType ,
2222 TableRowStyleType ,
2323 TableStyleType ,
24+ ThemeDetail ,
2425 TableToolbarStyleType ,
2526} from "comps/controls/styleControlConstants" ;
2627import { CompNameContext , EditorContext } from "comps/editorState" ;
@@ -29,7 +30,7 @@ import { PrimaryColor } from "constants/style";
2930import { trans } from "i18n" ;
3031import _ from "lodash" ;
3132import { 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" ;
3334import { Resizable } from "react-resizable" ;
3435import styled , { css } from "styled-components" ;
3536import { useUserViewMode } from "util/hooks" ;
@@ -41,15 +42,6 @@ import { messageInstance } from "lowcoder-design";
4142import { ReactRef , ResizeHandleAxis } from "layout/gridLayoutPropTypes" ;
4243import { CellColorViewType } from "./column/tableColumnComp" ;
4344
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- ` ;
5345
5446function genLinerGradient ( color : string ) {
5547 return `linear-gradient(${ color } , ${ color } )` ;
@@ -65,10 +57,11 @@ const getStyle = (
6557 const selectedRowBackground = genLinerGradient ( rowStyle . selectedRowBackground ) ;
6658 const hoverRowBackground = genLinerGradient ( rowStyle . hoverRowBackground ) ;
6759 const alternateBackground = genLinerGradient ( rowStyle . alternateBackground ) ;
60+ // const tableAutoHeight =
6861
6962 return css `
7063 .ant-table-body {
71- background : white ;
64+ background: ${ genLinerGradient ( style . background ) } ;
7265 }
7366 .ant-table-tbody {
7467 > tr:nth-of-type(2n + 1) {
@@ -130,6 +123,32 @@ const getStyle = (
130123 ` ;
131124} ;
132125
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
133152const TableWrapper = styled . div < {
134153 $style : TableStyleType ;
135154 $headerStyle : TableHeaderStyleType ;
@@ -139,16 +158,10 @@ const TableWrapper = styled.div<{
139158 $fixedHeader : boolean ;
140159 $fixedToolbar : boolean ;
141160} > `
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;
149162
150163 .ant-table-wrapper {
151- border-top: ${ ( props ) => ( props . $toolbarPosition === "above" ? "1px solid" : " unset" ) } ;
164+ border-top: unset;
152165 border-color: inherit;
153166 }
154167
@@ -299,6 +312,7 @@ const TableTh = styled.th<{ width?: number }>`
299312const TableTd = styled . td < {
300313 $background : string ;
301314 $style : TableColumnStyleType & { rowHeight ?: string } ;
315+ $defaultThemeDetail : ThemeDetail ;
302316 $linkStyle ?: TableColumnLinkStyleType ;
303317 $isEditing : boolean ;
304318 $tableSize ?: string ;
@@ -316,40 +330,42 @@ const TableTd = styled.td<{
316330 border-color: ${ ( props ) => props . $style . border } !important;
317331 border-width: ${ ( props ) => props . $style . borderWidth } !important;
318332 border-radius: ${ ( props ) => props . $style . radius } ;
319- margin: ${ ( props ) => props . $style . margin } ;
320333
321334 padding: 0 !important;
322335
323336 > div {
337+ margin: ${ ( props ) => props . $style . margin } ;
324338 color: ${ ( props ) => props . $style . text } ;
325- font-size: ${ ( props ) => props . $style . textSize } ;
326- line-height: 21px;
327-
339+
328340 ${ ( 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;
331345 ${ ! props . $autoHeight && `
332346 overflow-y: auto;
333- max-height: ${ props . $style . rowHeight || '39px ' } ;
347+ max-height: ${ props . $style . rowHeight || '28px ' } ;
334348 ` } ;
335349 ` } ;
336350 ${ ( 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;
339355 ${ ! props . $autoHeight && `
340356 overflow-y: auto;
341- max-height: ${ props . $style . rowHeight || '47px ' } ;
357+ max-height: ${ props . $style . rowHeight || '48px ' } ;
342358 ` } ;
343359 ` } ;
344360 ${ ( 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' } ;
347364 ${ ! props . $autoHeight && `
348365 overflow-y: auto;
349- max-height: ${ props . $style . rowHeight || '55px ' } ;
366+ max-height: ${ props . $style . rowHeight || '96px ' } ;
350367 ` } ;
351368 ` } ;
352-
353369
354370 > div > .ant-badge > .ant-badge-status-text,
355371 > div > div > .markdown-body {
@@ -516,6 +532,7 @@ function TableCellView(props: {
516532 { ...restProps }
517533 $background = { background }
518534 $style = { style }
535+ $defaultThemeDetail = { defaultTheme }
519536 $linkStyle = { linkStyle }
520537 $isEditing = { editing }
521538 $tableSize = { tableSize }
@@ -656,6 +673,7 @@ export function TableCompView(props: {
656673 const [ loading , setLoading ] = useState ( false ) ;
657674 const { comp, onDownload, onRefresh } = props ;
658675 const compChildren = comp . children ;
676+ const tableAutoHeight = compChildren . autoHeight . getView ( ) ;
659677 const style = compChildren . style . getView ( ) ;
660678 const rowStyle = compChildren . rowStyle . getView ( ) ;
661679 const headerStyle = compChildren . headerStyle . getView ( ) ;
@@ -768,57 +786,64 @@ export function TableCompView(props: {
768786
769787 return (
770788 < 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 ( ) }
780792 >
781793 { 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 ( )
791837 }
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 >
816844 { 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+
822847 </ BackgroundColorContext . Provider >
823848 ) ;
824849}
0 commit comments