@@ -21,38 +21,38 @@ const StyledRow = styled.tr`
2121 &:nth-child(2n) {
2222 background: ${ getColor ( "tableRowBg" ) } ;
2323 }
24+ width: fit-content;
2425`
2526const StyledHeaderRow = styled . tr `
2627 background: ${ getColor ( "tableRowBg" ) } ;
2728 color: ${ getColor ( "text" ) } ;
2829`
2930const StyledHeaderCell = styled ( Box ) `
31+ position: relative;
3032 padding: 12px;
3133 border-bottom: 1px solid ${ getColor ( "borderSecondary" ) } ;
3234 &:not(:last-child) {
3335 border-right: 1px solid ${ getColor ( "borderSecondary" ) } ;
3436 }
3537`
3638const StyledSortIcon = styled ( Icon ) `
39+ position: relative;
40+ top: 0;
41+ bottom: 0;
3742 height: 16px;
38- margin: auto 4px;
3943 width: 16px;
44+ margin: auto;
4045`
4146const StyledPagination = styled ( Flex ) `
4247 height: 45px;
4348 background: ${ getColor ( "mainBackground" ) } ;
4449 border-top: 1px solid ${ getColor ( "borderSecondary" ) } ;
4550`
4651
47- const Table = forwardRef ( ( { children, ...props } , ref ) => {
52+ const Table = forwardRef ( ( { children, width , ...props } , ref ) => {
4853 return (
49- < Flex width = { { base : "100%" , min : "fit-content" } } height = "100%" column >
50- < Box
51- sx = { { borderCollapse : "separate" , position : "relative" } }
52- ref = { ref }
53- as = "table"
54- { ...props }
55- >
54+ < Flex height = "100%" width = "100%" column >
55+ < Box sx = { { borderCollapse : "separate" } } ref = { ref } as = "table" width = { width } { ...props } >
5656 { children }
5757 </ Box >
5858 </ Flex >
@@ -76,13 +76,64 @@ Table.HeadRow = forwardRef(({ children, ...props }, ref) => (
7676 </ StyledHeaderRow >
7777) )
7878
79+ Table . Resizer = ( { onMouseDown, onTouchStart, deltaOffset, getIsResizing } ) => {
80+ if ( ! onMouseDown ) return
81+ const resizingProps = getIsResizing ( ) ? { transform : `translateX(${ deltaOffset } px)` } : { }
82+
83+ return (
84+ < Box
85+ _hover = { { background : "resizerLine" , color : "resizerLine" } }
86+ _active = { { background : "resizerLine" , color : "resizerLine" } }
87+ sx = { {
88+ width : "2px" ,
89+ userSelect : "none" ,
90+ touchAction : "none" ,
91+ cursor : "col-resize" ,
92+ color : "border" ,
93+ "&::before" : {
94+ content : '":"' ,
95+ position : "absolute" ,
96+ top : "0" ,
97+ bottom : "0" ,
98+ display : "flex" ,
99+ alignItems : "center" ,
100+ left : "-8px" ,
101+ width : "8px" ,
102+ } ,
103+ ...resizingProps ,
104+ } }
105+ onMouseDown = { onMouseDown }
106+ onTouchStart = { onTouchStart }
107+ background = "borderSecondary"
108+ position = "absolute"
109+ top = { 0 }
110+ right = { 0 }
111+ bottom = { 0 }
112+ />
113+ )
114+ }
115+
79116Table . HeadCell = forwardRef (
80117 (
81- { align = "left" , children, headStyles = { } , maxWidth, minWidth, width, styles = { } , ...rest } ,
118+ {
119+ children,
120+ align = "left" ,
121+ width,
122+ maxWidth,
123+ minWidth,
124+ tooltipText,
125+ filter,
126+ onMouseDown,
127+ onTouchStart,
128+ getIsResizing,
129+ deltaOffset,
130+ styles = { } ,
131+ headStyles = { } ,
132+ ...props
133+ } ,
82134 ref
83135 ) => (
84136 < StyledHeaderCell
85- width = { { max : maxWidth , base : width , min : minWidth } }
86137 ref = { ref }
87138 sx = { {
88139 textAlign : align ,
@@ -93,31 +144,50 @@ Table.HeadCell = forwardRef(
93144 ...styles ,
94145 ...headStyles ,
95146 } }
147+ width = { `${ width } px` }
96148 as = "th"
97- { ...rest }
149+ { ...props }
98150 >
99- { children }
151+ < Flex >
152+ { children }
153+ < Box sx = { { marginLeft : "auto" } } position = "relative" top = { 0 } >
154+ { tooltipText && (
155+ < Tooltip align = "bottom" content = { tooltipText } >
156+ < Icon color = "nodeBadgeColor" size = "small" name = "information" />
157+ </ Tooltip >
158+ ) }
159+ </ Box >
160+ </ Flex >
161+
162+ { filter }
163+ < Table . Resizer
164+ onMouseDown = { onMouseDown }
165+ onTouchStart = { onTouchStart }
166+ getIsResizing = { getIsResizing }
167+ deltaOffset = { deltaOffset }
168+ />
100169 </ StyledHeaderCell >
101170 )
102171)
103172
104173Table . SortingHeadCell = forwardRef (
105174 (
106175 {
107- align = "left" ,
108176 children,
109- "data-testid" : dataTestid ,
110- filter,
111- headStyles = { } ,
112- maxWidth,
113- minWidth,
114177 onSortClicked,
115178 setSortDirection,
116- "sortby-testid" : sortbyTestid ,
179+ maxWidth,
180+ width,
181+ minWidth,
117182 sortDirection,
183+ filter,
184+ align = "left" ,
185+ "data-testid" : dataTestid ,
186+ "sortby-testid" : sortbyTestid ,
118187 styles = { } ,
119- width,
120- ...rest
188+ headStyles = { } ,
189+ tooltipText,
190+ ...props
121191 } ,
122192 ref
123193 ) => {
@@ -140,40 +210,38 @@ Table.SortingHeadCell = forwardRef(
140210 )
141211
142212 return (
143- < StyledHeaderCell
144- width = { { max : maxWidth , base : width , min : minWidth } }
145- as = "th"
213+ < Table . HeadCell
214+ styles = { styles }
215+ align = { align }
146216 ref = { ref }
147- { ...rest }
148- sx = { {
149- textAlign : align ,
150- fontSize : "14px" ,
151- height : "90px" ,
152- position : "sticky" ,
153- top : 0 ,
154- ...styles ,
155- ...headStyles ,
156- } }
157217 data-testid = { dataTestid }
218+ maxWidth = { maxWidth }
219+ width = { width }
220+ minWidth = { minWidth }
221+ tooltipText = { tooltipText }
222+ headStyles = { headStyles }
223+ { ...props }
224+ filter = { filter }
158225 >
159- < Flex
160- cursor = "pointer"
161- data-testid = { sortbyTestid }
162- onClick = { onClick }
226+ < Box
163227 onMouseEnter = { onMouseEnter }
164228 onMouseLeave = { onMouseLeave }
229+ onClick = { onClick }
165230 position = "relative"
231+ cursor = "pointer"
232+ data-testid = { sortbyTestid }
166233 >
167- { children }
168- < StyledSortIcon color = "text" name = { sortingIcons [ sortDirection ] ?? null } />
169- { showHoveringIcon ? (
170- < StyledSortIcon color = "textLite" name = { sortingIcons [ "indicator" ] } />
171- ) : (
172- < Box width = { 6 } height = { 4 } />
173- ) }
174- </ Flex >
175- { filter }
176- </ StyledHeaderCell >
234+ < Flex data-testid = "sorting-cell-children-sorting-arrows-wrapper" >
235+ { children }
236+ < Box width = { 4 } >
237+ < StyledSortIcon color = "text" name = { sortingIcons [ sortDirection ] ?? null } />
238+ { showHoveringIcon && (
239+ < StyledSortIcon color = "textLite" name = { sortingIcons [ "indicator" ] } />
240+ ) }
241+ </ Box >
242+ </ Flex >
243+ </ Box >
244+ </ Table . HeadCell >
177245 )
178246 }
179247)
@@ -187,32 +255,39 @@ Table.Body = forwardRef(({ children, ...props }, ref) => (
187255Table . Cell = forwardRef (
188256 (
189257 {
190- align = "left" ,
191- cellStyles = { } ,
192258 children,
259+ onClick,
260+ width,
193261 maxWidth,
194262 minWidth,
195- onClick,
263+ align = "left" ,
264+ cellStyles = { } ,
196265 styles = { } ,
197- width,
198- ...rest
266+ ...props
199267 } ,
200268 ref
201269 ) => {
202270 const handleClick = e => {
203271 e . persist ( )
204- if ( rest . stopPropagation ) e . stopPropagation ( )
272+ if ( props . stopPropagation ) e . stopPropagation ( )
205273 onClick ?. ( )
206274 }
207275 return (
208276 < Box
209- width = { { max : maxWidth , base : width , min : minWidth } }
277+ width = { { max : ` ${ maxWidth } px` , base : ` ${ width } px` , min : ` ${ minWidth } px` } }
210278 padding = { [ 3 ] }
211- sx = { { textAlign : align , height : "80px" , ...styles , ...cellStyles } }
279+ sx = { {
280+ textAlign : align ,
281+ height : "65px" ,
282+ maxHeight : "65px" ,
283+ whiteSpace : "nowrap" ,
284+ ...cellStyles ,
285+ ...styles ,
286+ } }
212287 as = "td"
213288 ref = { ref }
289+ { ...props }
214290 onClick = { handleClick }
215- { ...rest }
216291 >
217292 { children }
218293 </ Box >
0 commit comments