11// parts/TableContainer.tsx
22import React from 'react' ;
33import styled from 'styled-components' ;
4+ import SimpleBar from 'simplebar-react' ;
5+ import 'simplebar-react/dist/simplebar.min.css' ;
46
57const MainContainer = styled . div < {
68 $mode : 'AUTO' | 'FIXED' ;
79} > `
810 display: flex;
911 flex-direction: column;
1012 height: 100%;
11- overflow: hidden;
1213 position: relative;
13- border: 4px solid red;
1414` ;
1515
1616const StickyToolbar = styled . div < {
@@ -33,8 +33,34 @@ const DefaultToolbar = styled.div`
3333const TableSection = styled . div < {
3434 $mode : 'AUTO' | 'FIXED' ;
3535} > `
36- overflow: ${ props => props . $mode === 'FIXED' ? 'auto' : 'visible' } ;
36+
37+ flex: 1 1 auto;
38+ min-height: 0;
3739 border: 4px solid blue;
40+ overflow: hidden;
41+ ` ;
42+
43+
44+ const SimpleBarWrapper = styled ( SimpleBar ) < {
45+ $showVertical : boolean ;
46+ $showHorizontal : boolean ;
47+ } > `
48+ height: 100%;
49+ border: 4px solid red;
50+
51+ ${ props => ! props . $showVertical && `
52+ .simplebar-scrollbar[data-direction="vertical"] {
53+ opacity: 0 !important;
54+ pointer-events: none;
55+ }
56+ ` }
57+
58+ ${ props => ! props . $showHorizontal && `
59+ .simplebar-scrollbar[data-direction="horizontal"] {
60+ opacity: 0 !important;
61+ pointer-events: none;
62+ }
63+ ` }
3864` ;
3965
4066interface TableContainerProps {
@@ -45,6 +71,8 @@ interface TableContainerProps {
4571 toolbar : React . ReactNode ;
4672 children : React . ReactNode ;
4773 containerRef ?: React . RefObject < HTMLDivElement > ;
74+ showVerticalScrollbar : boolean ;
75+ showHorizontalScrollbar : boolean ;
4876}
4977
5078export const TableContainer : React . FC < TableContainerProps > = ( {
@@ -54,25 +82,36 @@ export const TableContainer: React.FC<TableContainerProps> = ({
5482 showToolbar,
5583 toolbar,
5684 children,
57- containerRef
85+ containerRef,
86+ showVerticalScrollbar,
87+ showHorizontalScrollbar
5888} ) => {
5989
6090
6191 return (
6292 < MainContainer $mode = { mode } ref = { containerRef } >
93+ { stickyToolbar && toolbarPosition === 'above' && (
94+ < StickyToolbar $position = "above" > { toolbar } </ StickyToolbar >
95+ ) }
6396 < TableSection $mode = { mode } >
64- { showToolbar && toolbarPosition === 'above' && (
65- stickyToolbar
66- ? < StickyToolbar $position = "above" > { toolbar } </ StickyToolbar >
67- : < DefaultToolbar > { toolbar } </ DefaultToolbar >
97+
98+ < SimpleBarWrapper
99+ $showVertical = { showVerticalScrollbar }
100+ $showHorizontal = { showHorizontalScrollbar }
101+ >
102+ { ! stickyToolbar && toolbarPosition === 'above' && (
103+ < DefaultToolbar > { toolbar } </ DefaultToolbar >
68104 ) }
69- { children }
70- { showToolbar && toolbarPosition === 'below' && (
71- stickyToolbar
72- ? < StickyToolbar $position = "below" > { toolbar } </ StickyToolbar >
73- : < DefaultToolbar > { toolbar } </ DefaultToolbar >
105+ { children }
106+ { ! stickyToolbar && toolbarPosition === 'below' && (
107+ < DefaultToolbar > { toolbar } </ DefaultToolbar >
74108 ) }
109+ </ SimpleBarWrapper >
110+
75111 </ TableSection >
112+ { stickyToolbar && toolbarPosition === 'below' && (
113+ < StickyToolbar $position = "below" > { toolbar } </ StickyToolbar >
114+ ) }
76115 </ MainContainer >
77116 ) ;
78117} ;
0 commit comments