@trackunit/react-table 0.0.523 → 0.0.524

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/index.cjs.js CHANGED
@@ -684,10 +684,14 @@ const useTableSelection = ({ data, defaultSelectedIds, enableRowSelection = true
684
684
  setRowSelection(() => ({ ...initialSelection }));
685
685
  }, [defaultSelectedIds]);
686
686
  const toggleRowSelectionState = React.useCallback((id) => {
687
- setRowSelection(prevRowSelection => ({
688
- ...prevRowSelection,
689
- [id]: !prevRowSelection[id],
690
- }));
687
+ setRowSelection(prevRowSelection => {
688
+ const newSelection = { ...prevRowSelection, [id]: !prevRowSelection[id] };
689
+ const entries = sharedUtils.objectEntries(newSelection);
690
+ if (entries.length !== 0 && entries.every(([_, selected]) => !selected)) {
691
+ return {};
692
+ }
693
+ return newSelection;
694
+ });
691
695
  }, []);
692
696
  const selectedIds = React.useMemo(() => sharedUtils.objectEntries(rowSelection)
693
697
  .filter(([_, selected]) => selected)
package/index.esm.js CHANGED
@@ -665,10 +665,14 @@ const useTableSelection = ({ data, defaultSelectedIds, enableRowSelection = true
665
665
  setRowSelection(() => ({ ...initialSelection }));
666
666
  }, [defaultSelectedIds]);
667
667
  const toggleRowSelectionState = useCallback((id) => {
668
- setRowSelection(prevRowSelection => ({
669
- ...prevRowSelection,
670
- [id]: !prevRowSelection[id],
671
- }));
668
+ setRowSelection(prevRowSelection => {
669
+ const newSelection = { ...prevRowSelection, [id]: !prevRowSelection[id] };
670
+ const entries = objectEntries(newSelection);
671
+ if (entries.length !== 0 && entries.every(([_, selected]) => !selected)) {
672
+ return {};
673
+ }
674
+ return newSelection;
675
+ });
672
676
  }, []);
673
677
  const selectedIds = useMemo(() => objectEntries(rowSelection)
674
678
  .filter(([_, selected]) => selected)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/react-table",
3
- "version": "0.0.523",
3
+ "version": "0.0.524",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {