@@ -2,7 +2,7 @@ import { Table } from "antd";
2
2
import { TableProps } from "antd/es/table" ;
3
3
import { TableCellContext , TableRowContext } from "comps/comps/tableComp/tableContext" ;
4
4
import { TableToolbar } from "comps/comps/tableComp/tableToolbarComp" ;
5
- import { RowColorViewType } from "comps/comps/tableComp/tableTypes" ;
5
+ import { RowColorViewType , RowHeightViewType } from "comps/comps/tableComp/tableTypes" ;
6
6
import {
7
7
COL_MIN_WIDTH ,
8
8
COLUMN_CHILDREN_KEY ,
@@ -169,6 +169,10 @@ const TableWrapper = styled.div<{
169
169
border-top: none !important;
170
170
border-inline-start: none !important;
171
171
172
+ &::after {
173
+ box-shadow: none !important;
174
+ }
175
+
172
176
.ant-table-content {
173
177
overflow: unset !important;
174
178
}
@@ -280,8 +284,10 @@ const TableTh = styled.th<{ width?: number }>`
280
284
281
285
const TableTd = styled . td < {
282
286
background : string ;
283
- $style : TableColumnStyleType ;
287
+ $style : TableColumnStyleType & { rowHeight ?: string } ;
284
288
$isEditing : boolean ;
289
+ $tableSize ?: string ;
290
+ $autoHeight ?: boolean ;
285
291
} > `
286
292
.ant-table-row-expand-icon,
287
293
.ant-table-row-indent {
@@ -291,16 +297,42 @@ const TableTd = styled.td<{
291
297
background: ${ ( props ) => props . background } ;
292
298
border-color: ${ ( props ) => props . $style . border } ;
293
299
}
294
-
295
300
background: ${ ( props ) => props . background } !important;
296
301
border-color: ${ ( props ) => props . $style . border } !important;
297
302
border-width: ${ ( props ) => props . $style . borderWidth } !important;
298
303
border-radius: ${ ( props ) => props . $style . radius } ;
299
304
padding: 0 !important;
300
305
301
- > div > div {
306
+ > div {
302
307
color: ${ ( props ) => props . $style . text } ;
303
308
font-size: ${ ( props ) => props . $style . textSize } ;
309
+ line-height: 21px;
310
+
311
+ ${ ( props ) => props . $tableSize === 'small' && `
312
+ padding: 8.5px 8px;
313
+ min-height: ${ props . $style . rowHeight || '39px' } ;
314
+ ${ ! props . $autoHeight && `
315
+ overflow-y: auto;
316
+ max-height: ${ props . $style . rowHeight || '39px' } ;
317
+ ` } ;
318
+ ` } ;
319
+ ${ ( props ) => props . $tableSize === 'middle' && `
320
+ padding: 12.5px 8px;
321
+ min-height: ${ props . $style . rowHeight || '47px' } ;
322
+ ${ ! props . $autoHeight && `
323
+ overflow-y: auto;
324
+ max-height: ${ props . $style . rowHeight || '47px' } ;
325
+ ` } ;
326
+ ` } ;
327
+ ${ ( props ) => props . $tableSize === 'large' && `
328
+ padding: 16.5px 16px;
329
+ min-height: ${ props . $style . rowHeight || '55px' } ;
330
+ ${ ! props . $autoHeight && `
331
+ overflow-y: auto;
332
+ max-height: ${ props . $style . rowHeight || '55px' } ;
333
+ ` } ;
334
+ ` } ;
335
+
304
336
&,
305
337
> .ant-badge > .ant-badge-status-text,
306
338
> div > .markdown-body {
@@ -383,30 +415,40 @@ type CustomTableProps<RecordType> = Omit<TableProps<RecordType>, "components" |
383
415
columns : CustomColumnType < RecordType > [ ] ;
384
416
viewModeResizable : boolean ;
385
417
rowColorFn : RowColorViewType ;
418
+ rowHeightFn : RowHeightViewType ;
386
419
columnsStyle : TableColumnStyleType ;
420
+ size ?: string ;
421
+ rowAutoHeight ?: boolean ;
387
422
} ;
388
423
389
424
function TableCellView ( props : {
390
425
record : RecordType ;
391
426
title : string ;
392
427
rowColorFn : RowColorViewType ;
428
+ rowHeightFn : RowHeightViewType ;
393
429
cellColorFn : CellColorViewType ;
394
430
rowIndex : number ;
395
431
children : any ;
396
432
columnsStyle : TableColumnStyleType ;
397
433
columnStyle : TableColumnStyleType ;
434
+ tableSize ?: string ;
435
+ autoHeight ?: boolean ;
398
436
} ) {
399
437
const {
400
438
record,
401
439
title,
402
440
rowIndex,
403
441
rowColorFn,
442
+ rowHeightFn,
404
443
cellColorFn,
405
444
children,
406
445
columnsStyle,
407
446
columnStyle,
447
+ tableSize,
448
+ autoHeight,
408
449
...restProps
409
450
} = props ;
451
+
410
452
const [ editing , setEditing ] = useState ( false ) ;
411
453
const rowContext = useContext ( TableRowContext ) ;
412
454
let tdView ;
@@ -419,17 +461,24 @@ function TableCellView(props: {
419
461
currentOriginalIndex : record [ OB_ROW_ORI_INDEX ] ,
420
462
columnTitle : title ,
421
463
} ) ;
464
+ const rowHeight = rowHeightFn ( {
465
+ currentRow : record ,
466
+ currentIndex : rowIndex ,
467
+ currentOriginalIndex : record [ OB_ROW_ORI_INDEX ] ,
468
+ columnTitle : title ,
469
+ } ) ;
422
470
const cellColor = cellColorFn ( {
423
471
currentCell : record [ title . toLowerCase ( ) ] ,
424
472
} ) ;
425
473
426
- const style : TableColumnStyleType = {
474
+ const style = {
427
475
background : cellColor || rowColor || columnStyle . background || columnsStyle . background ,
428
476
text : columnStyle . text || columnsStyle . text ,
429
477
border : columnStyle . border || columnsStyle . border ,
430
478
radius : columnStyle . radius || columnsStyle . radius ,
431
479
borderWidth : columnStyle . borderWidth || columnsStyle . borderWidth ,
432
480
textSize : columnStyle . textSize || columnsStyle . textSize ,
481
+ rowHeight : rowHeight ,
433
482
}
434
483
let { background } = style ;
435
484
if ( rowContext . selected ) {
@@ -444,6 +493,8 @@ function TableCellView(props: {
444
493
background = { background }
445
494
$style = { style }
446
495
$isEditing = { editing }
496
+ $tableSize = { tableSize }
497
+ $autoHeight = { autoHeight }
447
498
>
448
499
{ children }
449
500
</ TableTd >
@@ -511,10 +562,13 @@ function ResizeableTable<RecordType extends object>(props: CustomTableProps<Reco
511
562
record,
512
563
title : col . titleText ,
513
564
rowColorFn : props . rowColorFn ,
565
+ rowHeightFn : props . rowHeightFn ,
514
566
cellColorFn : cellColorFn ,
515
567
rowIndex : rowIndex ,
516
568
columnsStyle : props . columnsStyle ,
517
569
columnStyle : style ,
570
+ tableSize : props . size ,
571
+ autoHeight : props . rowAutoHeight ,
518
572
} ) ,
519
573
onHeaderCell : ( ) => ( {
520
574
width : resizeWidth ,
@@ -583,6 +637,7 @@ export function TableCompView(props: {
583
637
const compChildren = comp . children ;
584
638
const style = compChildren . style . getView ( ) ;
585
639
const rowStyle = compChildren . rowStyle . getView ( ) ;
640
+ const rowAutoHeight = compChildren . rowAutoHeight . getView ( ) ;
586
641
const columnsStyle = compChildren . columnsStyle . getView ( ) ;
587
642
const changeSet = useMemo ( ( ) => compChildren . columns . getChangeSet ( ) , [ compChildren . columns ] ) ;
588
643
const hasChange = useMemo ( ( ) => ! _ . isEmpty ( changeSet ) , [ changeSet ] ) ;
@@ -610,7 +665,7 @@ export function TableCompView(props: {
610
665
size ,
611
666
dynamicColumn ,
612
667
dynamicColumnConfig ,
613
- columnsAggrData
668
+ columnsAggrData ,
614
669
) ,
615
670
[
616
671
columnViews ,
@@ -711,6 +766,7 @@ export function TableCompView(props: {
711
766
}
712
767
} }
713
768
rowColorFn = { compChildren . rowColor . getView ( ) as any }
769
+ rowHeightFn = { compChildren . rowHeight . getView ( ) as any }
714
770
{ ...compChildren . selection . getView ( ) ( onEvent ) }
715
771
bordered = { ! compChildren . hideBordered . getView ( ) }
716
772
onChange = { ( pagination , filters , sorter , extra ) => {
@@ -722,6 +778,7 @@ export function TableCompView(props: {
722
778
viewModeResizable = { compChildren . viewModeResizable . getView ( ) }
723
779
dataSource = { pageDataInfo . data }
724
780
size = { compChildren . size . getView ( ) }
781
+ rowAutoHeight = { rowAutoHeight }
725
782
tableLayout = "fixed"
726
783
loading = {
727
784
loading ||
0 commit comments