@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.js CHANGED
@@ -1420,10 +1420,11 @@ function SortableTable({
1420
1420
  const startIndex = (page - 1) * pageSize;
1421
1421
  return sorted.slice(startIndex, startIndex + pageSize);
1422
1422
  }, [pagination, sorted]);
1423
- const selectableRows = selection ? data.filter((row) => !isRowDisabled?.(row) && !isRowSelectionDisabled?.(row)) : [];
1423
+ const selectedRows = selection ? sorted.filter(selection.isSelected) : [];
1424
+ const selectableRows = selection ? sorted.filter((row) => !isRowDisabled?.(row) && !isRowSelectionDisabled?.(row)) : [];
1424
1425
  const selectedRowCount = selection ? selectableRows.filter(selection.isSelected).length : 0;
1425
1426
  const allRowsSelected = selectableRows.length > 0 && selectedRowCount === selectableRows.length;
1426
- const someRowsSelected = selectedRowCount > 0 && !allRowsSelected;
1427
+ const someRowsSelected = selectedRows.length > 0 && !allRowsSelected;
1427
1428
  const handleSortClick = (key) => {
1428
1429
  let nextDirection;
1429
1430
  if (!activeKey || !activeDirection) {
@@ -1460,14 +1461,15 @@ function SortableTable({
1460
1461
  {
1461
1462
  "aria-label": selection.selectAllLabel ?? "Select all rows",
1462
1463
  checked: allRowsSelected,
1463
- disabled: selectableRows.length === 0,
1464
+ disabled: selectableRows.length === 0 && selectedRows.length === 0,
1464
1465
  indeterminate: someRowsSelected,
1465
1466
  onCheckedChange: (checked) => {
1467
+ const rows = checked ? selectableRows : selectedRows;
1466
1468
  if (selection.onSelectAllChange) {
1467
- selection.onSelectAllChange(selectableRows, checked);
1469
+ selection.onSelectAllChange(rows, checked);
1468
1470
  return;
1469
1471
  }
1470
- selectableRows.forEach((row) => {
1472
+ rows.forEach((row) => {
1471
1473
  if (selection.isSelected(row) !== checked) {
1472
1474
  selection.onSelectedChange(row, checked);
1473
1475
  }