UNPKG

@rtdui/datatable

Version:

React DataTable component based on Rtdui components

21 lines (19 loc) 589 B
'use client'; function getSelectedRows(data, selectedIds, getRowId = (row) => row.id, getSubRows) { const selectedRows = []; const recurseRows = (rows, depth = 0) => rows.forEach((row, index) => { const rowId = String(getRowId(row)); const isSelected = selectedIds.includes(rowId); if (isSelected) { selectedRows.push(row); } const subRows = getSubRows?.(row); if (subRows?.length) { recurseRows(subRows, depth + 1); } }); recurseRows(data); return selectedRows; } export { getSelectedRows }; //# sourceMappingURL=getSelectedRows.mjs.map