@1771technologies/lytenyte-pro
Version:
Blazingly fast headless React data grid with 100s of features.
21 lines (20 loc) • 717 B
JavaScript
import { useEvent } from "@1771technologies/lytenyte-core/internal";
export function useRowsBetween(source) {
const rowsBetween = useEvent((startId, endId) => {
const left = source.flat.rowIdToRowIndex.get(startId);
const right = source.flat.rowIdToRowIndex.get(endId);
if (left == null || right == null)
return [];
const start = Math.min(left, right);
const end = Math.max(left, right);
const ids = [];
for (let i = start; i <= end + 1; i++) {
const row = source.flat.rowIndexToRow.get(i);
if (!row)
continue;
ids.push(row.id);
}
return ids;
});
return rowsBetween;
}