@@ -21,38 +21,38 @@ const StyledRow = styled.tr`
21
21
&:nth-child(2n) {
22
22
background: ${ getColor ( "tableRowBg" ) } ;
23
23
}
24
+ width: fit-content;
24
25
`
25
26
const StyledHeaderRow = styled . tr `
26
27
background: ${ getColor ( "tableRowBg" ) } ;
27
28
color: ${ getColor ( "text" ) } ;
28
29
`
29
30
const StyledHeaderCell = styled ( Box ) `
31
+ position: relative;
30
32
padding: 12px;
31
33
border-bottom: 1px solid ${ getColor ( "borderSecondary" ) } ;
32
34
&:not(:last-child) {
33
35
border-right: 1px solid ${ getColor ( "borderSecondary" ) } ;
34
36
}
35
37
`
36
38
const StyledSortIcon = styled ( Icon ) `
39
+ position: relative;
40
+ top: 0;
41
+ bottom: 0;
37
42
height: 16px;
38
- margin: auto 4px;
39
43
width: 16px;
44
+ margin: auto;
40
45
`
41
46
const StyledPagination = styled ( Flex ) `
42
47
height: 45px;
43
48
background: ${ getColor ( "mainBackground" ) } ;
44
49
border-top: 1px solid ${ getColor ( "borderSecondary" ) } ;
45
50
`
46
51
47
- const Table = forwardRef ( ( { children, ...props } , ref ) => {
52
+ const Table = forwardRef ( ( { children, width , ...props } , ref ) => {
48
53
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 } >
56
56
{ children }
57
57
</ Box >
58
58
</ Flex >
@@ -76,13 +76,64 @@ Table.HeadRow = forwardRef(({ children, ...props }, ref) => (
76
76
</ StyledHeaderRow >
77
77
) )
78
78
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
+
79
116
Table . HeadCell = forwardRef (
80
117
(
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
+ } ,
82
134
ref
83
135
) => (
84
136
< StyledHeaderCell
85
- width = { { max : maxWidth , base : width , min : minWidth } }
86
137
ref = { ref }
87
138
sx = { {
88
139
textAlign : align ,
@@ -93,31 +144,50 @@ Table.HeadCell = forwardRef(
93
144
...styles ,
94
145
...headStyles ,
95
146
} }
147
+ width = { `${ width } px` }
96
148
as = "th"
97
- { ...rest }
149
+ { ...props }
98
150
>
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
+ />
100
169
</ StyledHeaderCell >
101
170
)
102
171
)
103
172
104
173
Table . SortingHeadCell = forwardRef (
105
174
(
106
175
{
107
- align = "left" ,
108
176
children,
109
- "data-testid" : dataTestid ,
110
- filter,
111
- headStyles = { } ,
112
- maxWidth,
113
- minWidth,
114
177
onSortClicked,
115
178
setSortDirection,
116
- "sortby-testid" : sortbyTestid ,
179
+ maxWidth,
180
+ width,
181
+ minWidth,
117
182
sortDirection,
183
+ filter,
184
+ align = "left" ,
185
+ "data-testid" : dataTestid ,
186
+ "sortby-testid" : sortbyTestid ,
118
187
styles = { } ,
119
- width,
120
- ...rest
188
+ headStyles = { } ,
189
+ tooltipText,
190
+ ...props
121
191
} ,
122
192
ref
123
193
) => {
@@ -140,40 +210,38 @@ Table.SortingHeadCell = forwardRef(
140
210
)
141
211
142
212
return (
143
- < StyledHeaderCell
144
- width = { { max : maxWidth , base : width , min : minWidth } }
145
- as = "th"
213
+ < Table . HeadCell
214
+ styles = { styles }
215
+ align = { align }
146
216
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
- } }
157
217
data-testid = { dataTestid }
218
+ maxWidth = { maxWidth }
219
+ width = { width }
220
+ minWidth = { minWidth }
221
+ tooltipText = { tooltipText }
222
+ headStyles = { headStyles }
223
+ { ...props }
224
+ filter = { filter }
158
225
>
159
- < Flex
160
- cursor = "pointer"
161
- data-testid = { sortbyTestid }
162
- onClick = { onClick }
226
+ < Box
163
227
onMouseEnter = { onMouseEnter }
164
228
onMouseLeave = { onMouseLeave }
229
+ onClick = { onClick }
165
230
position = "relative"
231
+ cursor = "pointer"
232
+ data-testid = { sortbyTestid }
166
233
>
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 >
177
245
)
178
246
}
179
247
)
@@ -187,32 +255,39 @@ Table.Body = forwardRef(({ children, ...props }, ref) => (
187
255
Table . Cell = forwardRef (
188
256
(
189
257
{
190
- align = "left" ,
191
- cellStyles = { } ,
192
258
children,
259
+ onClick,
260
+ width,
193
261
maxWidth,
194
262
minWidth,
195
- onClick,
263
+ align = "left" ,
264
+ cellStyles = { } ,
196
265
styles = { } ,
197
- width,
198
- ...rest
266
+ ...props
199
267
} ,
200
268
ref
201
269
) => {
202
270
const handleClick = e => {
203
271
e . persist ( )
204
- if ( rest . stopPropagation ) e . stopPropagation ( )
272
+ if ( props . stopPropagation ) e . stopPropagation ( )
205
273
onClick ?. ( )
206
274
}
207
275
return (
208
276
< Box
209
- width = { { max : maxWidth , base : width , min : minWidth } }
277
+ width = { { max : ` ${ maxWidth } px` , base : ` ${ width } px` , min : ` ${ minWidth } px` } }
210
278
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
+ } }
212
287
as = "td"
213
288
ref = { ref }
289
+ { ...props }
214
290
onClick = { handleClick }
215
- { ...rest }
216
291
>
217
292
{ children }
218
293
</ Box >
0 commit comments