Drag To Select Table (#1064)

* - added drag to select on EntityTable

* - moved dragToSelect to own component

* - convert DragSelect to a generic component

* - fixed unused vars

* formatting

---------

Co-authored-by: Charles Bochet <charlesBochet@users.noreply.github.com>
This commit is contained in:
brendanlaschke
2023-08-05 01:16:01 +02:00
committed by GitHub
parent b6e1853d9f
commit 5e6351e099
5 changed files with 92 additions and 4 deletions
@@ -1,3 +1,4 @@
import { Ref } from 'react';
import { useRecoilValue } from 'recoil';
import { isNavbarSwitchingSizeState } from '@/ui/layout/states/isNavbarSwitchingSizeState';
@@ -9,7 +10,11 @@ import { tableRowIdsState } from '../states/tableRowIdsState';
import { EntityTableRow } from './EntityTableRow';
export function EntityTableBody() {
type OwnProps = {
tbodyRef: Ref<HTMLTableSectionElement>;
};
export function EntityTableBody({ tbodyRef }: OwnProps) {
const rowIds = useRecoilValue(tableRowIdsState);
const isNavbarSwitchingSize = useRecoilValue(isNavbarSwitchingSizeState);
@@ -23,7 +28,7 @@ export function EntityTableBody() {
}
return (
<tbody>
<tbody ref={tbodyRef}>
{rowIds.map((rowId, index) => (
<RowIdContext.Provider value={rowId} key={rowId}>
<RowIndexContext.Provider value={index}>