File tree Expand file tree Collapse file tree 4 files changed +47
-3
lines changed Expand file tree Collapse file tree 4 files changed +47
-3
lines changed Original file line number Diff line number Diff line change @@ -52,6 +52,7 @@ export const TableComponent = (
52
52
>
53
53
< TableCaptionStyled id = { uniqueId } > { props . captionDescription } </ TableCaptionStyled >
54
54
< TableRowGroupHeaderStyled
55
+ $scrolling = { props . scrolling }
55
56
hidden = { props . hiddenHeaderOn ?. [ props . device ] }
56
57
lineSeparatorBottomOnHeader = { props . lineSeparatorBottomOnHeader }
57
58
lineSeparatorLineStyles = { props . lineSeparatorLineStyles }
Original file line number Diff line number Diff line change 5
5
LineSeparatorPositionType ,
6
6
} from '@/components/lineSeparator' ;
7
7
import { srOnlyMixin } from '@/styles/mixins/srOnly.mixin' ;
8
- import { CommonStyleType } from '@/types' ;
8
+ import { CommonStyleType , DeviceBreakpointsType } from '@/types' ;
9
9
import { getStyles , getTypographyStyles } from '@/utils/getStyles/getStyles' ;
10
10
11
11
import {
@@ -59,6 +59,7 @@ export const TableRowGroupHeaderStyled = styled.thead<{
59
59
lineSeparatorLineStyles ?: LineSeparatorLinePropsStylesType ;
60
60
lineSeparatorTopOnHeader ?: boolean ;
61
61
lineSeparatorBottomOnHeader ?: boolean ;
62
+ $scrolling ?: boolean ;
62
63
} > `
63
64
${ ( { styles } ) => getStyles ( styles ?. container ) }
64
65
${ ( { styles } ) => getTypographyStyles ( styles ?. typography ) }
@@ -77,6 +78,27 @@ export const TableRowGroupHeaderStyled = styled.thead<{
77
78
}
78
79
return lineSeparator ;
79
80
} }
81
+ ${ ( ) =>
82
+ ( {
83
+ theme : {
84
+ MEDIA_QUERIES : { onlyDesktop } ,
85
+ } ,
86
+ styles,
87
+ $scrolling,
88
+ } ) => {
89
+ return css `
90
+ ${ onlyDesktop } {
91
+ ${ $scrolling
92
+ ? css `
93
+ box-shadow: ${ styles ?. container ?. [ DeviceBreakpointsType . DESKTOP ] ?. box_shadow ??
94
+ 'none' } ;
95
+ `
96
+ : css `
97
+ box-shadow: none;
98
+ ` }
99
+ }
100
+ ` ;
101
+ } }
80
102
` ;
81
103
82
104
export const TableRowHeaderStyled = styled . tr < {
Original file line number Diff line number Diff line change @@ -27,12 +27,28 @@ const TableComponent = React.forwardRef(
27
27
) ;
28
28
const device = useMediaDevice ( ) ;
29
29
30
+ // Indicates if there is scrolling behind the table body to add shadow to column headers.
31
+ const [ scrollPosition , setScrollPosition ] = React . useState ( 0 ) ;
32
+ const refTableBody = React . useRef < HTMLTableSectionElement > ( null ) ;
33
+
34
+ React . useEffect ( ( ) => {
35
+ const updatePosition = ( ) => {
36
+ setScrollPosition ( refTableBody ?. current ?. scrollTop ?? 0 ) ;
37
+ } ;
38
+
39
+ refTableBody ?. current ?. addEventListener ( 'scroll' , updatePosition ) ;
40
+
41
+ return ( ) => refTableBody ?. current ?. removeEventListener ( 'scroll' , updatePosition ) ;
42
+ } , [ ] ) ;
43
+
30
44
return (
31
45
< TableStandAlone
32
46
{ ...props }
33
47
ref = { ref }
34
48
device = { device }
35
49
lineSeparatorLineStyles = { lineSeparatorLineStyles }
50
+ refTableBody = { refTableBody }
51
+ scrolling = { scrollPosition > 0 }
36
52
styles = { styles }
37
53
/>
38
54
) ;
@@ -47,7 +63,7 @@ const TableBoundary = <V extends string | unknown>(
47
63
< ErrorBoundary
48
64
fallBackComponent = {
49
65
< FallbackComponent >
50
- < TableStandAlone { ...( props as unknown as ITableStandAlone ) } />
66
+ < TableStandAlone { ...( props as unknown as ITableStandAlone ) } ref = { ref } scrolling = { false } />
51
67
</ FallbackComponent >
52
68
}
53
69
>
Original file line number Diff line number Diff line change @@ -138,6 +138,7 @@ type TableAriaAttributes = Pick<
138
138
*/
139
139
export interface ITableStandAlone extends TableAriaAttributes {
140
140
styles : TableRowHeaderTypes < string , string > ;
141
+ refTableBody ?: React . Ref < HTMLTableSectionElement > ;
141
142
lineSeparatorLineStyles : LineSeparatorLinePropsStylesType ;
142
143
lineSeparatorTopOnHeader ?: boolean ;
143
144
lineSeparatorBottomOnHeader ?: boolean ;
@@ -152,6 +153,7 @@ export interface ITableStandAlone extends TableAriaAttributes {
152
153
dataTestId ?: string ;
153
154
hiddenHeaderOn ?: HiddenType ;
154
155
device : DeviceBreakpointsType ;
156
+ scrolling : boolean ;
155
157
headerVariant ?: string ;
156
158
expandedContentHelpMessage ?: string ;
157
159
formatListInMobile ?: boolean ;
@@ -169,7 +171,10 @@ export interface ITableStandAlone extends TableAriaAttributes {
169
171
* @interface ITable
170
172
*/
171
173
export interface ITable < V = undefined extends string ? unknown : string >
172
- extends Omit < ITableStandAlone , 'styles' | 'lineSeparatorLineStyles' | 'device' > ,
174
+ extends Omit <
175
+ ITableStandAlone ,
176
+ 'styles' | 'lineSeparatorLineStyles' | 'device' | 'scrolling' | 'refTableBody'
177
+ > ,
173
178
Omit < CustomTokenTypes < TableRowHeaderTypes < string , string > > , 'cts' | 'extraCt' > {
174
179
variant : V ;
175
180
lineSeparatorLineVariant ?: string ;
You can’t perform that action at this time.
0 commit comments