| 549 | } |
| 550 | |
| 551 | const mutateRowIsSelected = <TData extends RowData>( |
| 552 | selectedRowIds: Record<string, boolean>, |
| 553 | id: string, |
| 554 | value: boolean, |
| 555 | includeChildren: boolean, |
| 556 | table: Table<TData>, |
| 557 | ) => { |
| 558 | const row = table.getRow(id, true) |
| 559 | |
| 560 | // const isGrouped = row.getIsGrouped() |
| 561 | |
| 562 | // if ( // TODO: enforce grouping row selection rules |
| 563 | // !isGrouped || |
| 564 | // (isGrouped && table.options.enableGroupingRowSelection) |
| 565 | // ) { |
| 566 | if (value) { |
| 567 | if (!row.getCanMultiSelect()) { |
| 568 | Object.keys(selectedRowIds).forEach((key) => delete selectedRowIds[key]) |
| 569 | } |
| 570 | if (row.getCanSelect()) { |
| 571 | selectedRowIds[id] = true |
| 572 | } |
| 573 | } else { |
| 574 | delete selectedRowIds[id] |
| 575 | } |
| 576 | // } |
| 577 | |
| 578 | if (includeChildren && row.subRows?.length && row.getCanSelectSubRows()) { |
| 579 | row.subRows.forEach((row) => |
| 580 | mutateRowIsSelected( |
| 581 | selectedRowIds, |
| 582 | row.id, |
| 583 | value, |
| 584 | includeChildren, |
| 585 | table, |
| 586 | ), |
| 587 | ) |
| 588 | } |
| 589 | } |
| 590 | |
| 591 | export function selectRowsFn<TData extends RowData>( |
| 592 | table: Table<TData>, |