seahaven-ap/src/dashboard/selection.ts

13 lines
450 B
TypeScript

import type { GridRowId, GridRowSelectionModel } from "@mui/x-data-grid";
/** Resolve selected row count for MUI DataGrid v8 include/exclude selection models. */
export function countSelectedRows(
selection: GridRowSelectionModel,
rowIds: readonly GridRowId[],
): number {
if (selection.type === "include") {
return rowIds.filter((id) => selection.ids.has(id)).length;
}
return rowIds.filter((id) => !selection.ids.has(id)).length;
}