schummar-table 0.5.0 → 0.5.3

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/README.md ADDED
@@ -0,0 +1,4 @@
1
+ # schummar-table
2
+
3
+ [![](https://badgen.net/npm/v/schummar-table)](https://www.npmjs.com/package/schummar-table)
4
+ [![](https://badgen.net/bundlephobia/minzip/schummar-table)](https://bundlephobia.com/package/schummar-table)
package/dist/cjs/index.js CHANGED
@@ -928,13 +928,15 @@ function calcProps(props) {
928
928
  }
929
929
  function cleanupState(state) {
930
930
  react.useEffect(() => state.addReaction((state2) => [state2.props.columns, state2.itemsById, state2.activeItemsById, state2.activeColumns], ([columns, itemsById, activeItemsById, activeColumns], draft) => {
931
- var _a, _b, _c, _d, _e, _f;
932
931
  const columnIds = new Set(columns.map((column) => column.id));
933
932
  const activeColumnIds = new Set(activeColumns.map((column) => column.id));
934
933
  const newSort = draft.sort.filter((s) => activeColumnIds.has(s.columnId));
935
934
  if (newSort.length < draft.sort.length) {
936
935
  draft.sort = newSort;
937
- (_b = (_a = draft.props).onSortChange) == null ? void 0 : _b.call(_a, newSort);
936
+ setTimeout(() => {
937
+ var _a, _b;
938
+ (_b = (_a = state.getState().props).onSortChange) == null ? void 0 : _b.call(_a, newSort);
939
+ });
938
940
  }
939
941
  for (const id of draft.filters.keys()) {
940
942
  if (!activeColumnIds.has(id))
@@ -960,12 +962,18 @@ function cleanupState(state) {
960
962
  const newSelection = intersect(draft.selection, activeItemsById);
961
963
  if (newSelection.size !== draft.selection.size) {
962
964
  draft.selection = newSelection;
963
- (_d = (_c = draft.props).onSelectionChange) == null ? void 0 : _d.call(_c, newSelection);
965
+ setTimeout(() => {
966
+ var _a, _b;
967
+ (_b = (_a = state.getState().props).onSelectionChange) == null ? void 0 : _b.call(_a, newSelection);
968
+ });
964
969
  }
965
970
  const newExpanded = intersect(draft.expanded, itemsById);
966
971
  if (newExpanded.size < draft.expanded.size) {
967
972
  draft.expanded = newExpanded;
968
- (_f = (_e = draft.props).onExpandedChange) == null ? void 0 : _f.call(_e, newExpanded);
973
+ setTimeout(() => {
974
+ var _a, _b;
975
+ (_b = (_a = state.getState().props).onExpandedChange) == null ? void 0 : _b.call(_a, newExpanded);
976
+ });
969
977
  }
970
978
  }
971
979
  }, { runNow: true }), [state]);
@@ -975,9 +983,8 @@ function filterColumns(state) {
975
983
  draft.activeColumns = orderBy(columns.filter((column) => !hiddenColumns.has(column.id)), [(column) => columnOrder.indexOf(column.id)]);
976
984
  }, { runNow: true }), [state]);
977
985
  }
978
- function syncSelections(state) {
979
- react.useEffect(() => state.addReaction((state2) => [state2.props.selectSyncChildren, state2.selection, state2.activeItems], ([selectSyncChildren, selection, activeItems], state2) => {
980
- var _a, _b;
986
+ function syncSelections(table) {
987
+ react.useEffect(() => table.addReaction((state) => [state.props.selectSyncChildren, state.selection, state.activeItems], ([selectSyncChildren, selection, activeItems], state) => {
981
988
  if (!selectSyncChildren)
982
989
  return;
983
990
  const newSelection = new Set(selection);
@@ -987,10 +994,13 @@ function syncSelections(state) {
987
994
  }
988
995
  }
989
996
  if (newSelection.size !== selection.size) {
990
- state2.selection = newSelection;
991
- (_b = (_a = state2.props).onSelectionChange) == null ? void 0 : _b.call(_a, newSelection);
997
+ state.selection = newSelection;
998
+ setTimeout(() => {
999
+ var _a, _b;
1000
+ (_b = (_a = table.getState().props).onSelectionChange) == null ? void 0 : _b.call(_a, newSelection);
1001
+ });
992
1002
  }
993
- }, { runNow: true }), [state]);
1003
+ }, { runNow: true }), [table]);
994
1004
  }
995
1005
  function useTableState(_props) {
996
1006
  const props = calcProps(_props);