-
Notifications
You must be signed in to change notification settings - Fork 228
Expand file tree
/
Copy pathRawTableRow.tsx
More file actions
45 lines (42 loc) · 1.33 KB
/
RawTableRow.tsx
File metadata and controls
45 lines (42 loc) · 1.33 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
import { selectedRowClassName, zebraStripe } from "./result-table-utils";
import RawTableValue from "./RawTableValue";
import type { Row } from "../../common/raw-result-types";
interface Props {
rowIndex: number;
row: Row;
databaseUri: string;
className?: string;
selectedColumn?: number;
selectedItemRef?: React.RefObject<HTMLTableCellElement | undefined>;
onSelected?: (row: number, column: number) => void;
}
export default function RawTableRow(props: Props) {
return (
<tr
key={props.rowIndex}
{...zebraStripe(props.rowIndex, props.className || "")}
>
<td key={-1}>{props.rowIndex + 1}</td>
{props.row.map((value, columnIndex) => {
const isSelected = props.selectedColumn === columnIndex;
return (
<td
ref={
isSelected && props.selectedItemRef?.current !== undefined
? (props.selectedItemRef as React.RefObject<HTMLTableCellElement>)
: undefined
}
key={columnIndex}
{...(isSelected ? { className: selectedRowClassName } : {})}
>
<RawTableValue
value={value}
databaseUri={props.databaseUri}
onSelected={() => props.onSelected?.(props.rowIndex, columnIndex)}
/>
</td>
);
})}
</tr>
);
}