-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Expand file tree
/
Copy pathSummaryRow.tsx
More file actions
80 lines (72 loc) · 1.82 KB
/
SummaryRow.tsx
File metadata and controls
80 lines (72 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import { memo } from 'react';
import { css } from 'ecij';
import { classnames } from './utils';
import type { RenderSummaryRowProps } from './types';
import { bottomSummaryRowClassname, rowClassname, topSummaryRowClassname } from './style/row';
import SummaryCell from './SummaryCell';
const summaryRow = css`
@layer rdg.SummaryRow {
position: sticky;
z-index: 2;
}
`;
const summaryRowClassname = `rdg-summary-row ${summaryRow}`;
function SummaryRow<R, SR>({
tabIndex,
className,
rowIdx,
gridRowStart,
row,
iterateOverViewportColumnsForRow,
activeCellIdx,
setActivePosition,
top,
bottom,
isTop,
'aria-rowindex': ariaRowIndex
}: RenderSummaryRowProps<R, SR>) {
const cells = iterateOverViewportColumnsForRow(activeCellIdx, { type: 'SUMMARY', row })
.map(([column, isCellActive, colSpan]) => (
<SummaryCell<R, SR>
key={column.key}
column={column}
colSpan={colSpan}
row={row}
rowIdx={rowIdx}
isCellActive={isCellActive}
setActivePosition={setActivePosition}
/>
))
.toArray();
return (
<div
role="row"
aria-rowindex={ariaRowIndex}
tabIndex={tabIndex}
className={classnames(
rowClassname,
`rdg-row-${rowIdx % 2 === 0 ? 'even' : 'odd'}`,
summaryRowClassname,
isTop ? topSummaryRowClassname : bottomSummaryRowClassname,
className
)}
style={{
gridRowStart,
top,
bottom
}}
>
{cells}
</div>
);
}
const SummaryRowComponent = memo(SummaryRow) as <R, SR>(
props: RenderSummaryRowProps<R, SR>
) => React.JSX.Element;
export default SummaryRowComponent;
export function defaultRenderSummaryRow<R, SR>(
key: React.Key,
props: RenderSummaryRowProps<R, SR>
) {
return <SummaryRowComponent key={key} {...props} />;
}