@mirror-physics/fractal-ui 0.2.0-next.68 → 0.2.0-next.69

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1524,10 +1524,11 @@ function SortableTable({
1524
1524
  const startIndex = (page - 1) * pageSize;
1525
1525
  return sorted.slice(startIndex, startIndex + pageSize);
1526
1526
  }, [pagination, sorted]);
1527
- const selectableRows = selection ? data.filter((row) => !isRowDisabled?.(row) && !isRowSelectionDisabled?.(row)) : [];
1527
+ const selectedRows = selection ? sorted.filter(selection.isSelected) : [];
1528
+ const selectableRows = selection ? sorted.filter((row) => !isRowDisabled?.(row) && !isRowSelectionDisabled?.(row)) : [];
1528
1529
  const selectedRowCount = selection ? selectableRows.filter(selection.isSelected).length : 0;
1529
1530
  const allRowsSelected = selectableRows.length > 0 && selectedRowCount === selectableRows.length;
1530
- const someRowsSelected = selectedRowCount > 0 && !allRowsSelected;
1531
+ const someRowsSelected = selectedRows.length > 0 && !allRowsSelected;
1531
1532
  const handleSortClick = (key) => {
1532
1533
  let nextDirection;
1533
1534
  if (!activeKey || !activeDirection) {
@@ -1564,14 +1565,15 @@ function SortableTable({
1564
1565
  {
1565
1566
  "aria-label": selection.selectAllLabel ?? "Select all rows",
1566
1567
  checked: allRowsSelected,
1567
- disabled: selectableRows.length === 0,
1568
+ disabled: selectableRows.length === 0 && selectedRows.length === 0,
1568
1569
  indeterminate: someRowsSelected,
1569
1570
  onCheckedChange: (checked) => {
1571
+ const rows = checked ? selectableRows : selectedRows;
1570
1572
  if (selection.onSelectAllChange) {
1571
- selection.onSelectAllChange(selectableRows, checked);
1573
+ selection.onSelectAllChange(rows, checked);
1572
1574
  return;
1573
1575
  }
1574
- selectableRows.forEach((row) => {
1576
+ rows.forEach((row) => {
1575
1577
  if (selection.isSelected(row) !== checked) {
1576
1578
  selection.onSelectedChange(row, checked);
1577
1579
  }