schummar-table 0.5.0-beta-8 → 0.5.2

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/es/index.js CHANGED
@@ -926,13 +926,15 @@ function calcProps(props) {
926
926
  }
927
927
  function cleanupState(state) {
928
928
  useEffect(() => state.addReaction((state2) => [state2.props.columns, state2.itemsById, state2.activeItemsById, state2.activeColumns], ([columns, itemsById, activeItemsById, activeColumns], draft) => {
929
- var _a, _b, _c, _d, _e, _f;
930
929
  const columnIds = new Set(columns.map((column) => column.id));
931
930
  const activeColumnIds = new Set(activeColumns.map((column) => column.id));
932
931
  const newSort = draft.sort.filter((s) => activeColumnIds.has(s.columnId));
933
932
  if (newSort.length < draft.sort.length) {
934
933
  draft.sort = newSort;
935
- (_b = (_a = draft.props).onSortChange) == null ? void 0 : _b.call(_a, newSort);
934
+ setTimeout(() => {
935
+ var _a, _b;
936
+ (_b = (_a = draft.props).onSortChange) == null ? void 0 : _b.call(_a, newSort);
937
+ });
936
938
  }
937
939
  for (const id of draft.filters.keys()) {
938
940
  if (!activeColumnIds.has(id))
@@ -958,12 +960,18 @@ function cleanupState(state) {
958
960
  const newSelection = intersect(draft.selection, activeItemsById);
959
961
  if (newSelection.size !== draft.selection.size) {
960
962
  draft.selection = newSelection;
961
- (_d = (_c = draft.props).onSelectionChange) == null ? void 0 : _d.call(_c, newSelection);
963
+ setTimeout(() => {
964
+ var _a, _b;
965
+ (_b = (_a = draft.props).onSelectionChange) == null ? void 0 : _b.call(_a, newSelection);
966
+ });
962
967
  }
963
968
  const newExpanded = intersect(draft.expanded, itemsById);
964
969
  if (newExpanded.size < draft.expanded.size) {
965
970
  draft.expanded = newExpanded;
966
- (_f = (_e = draft.props).onExpandedChange) == null ? void 0 : _f.call(_e, newExpanded);
971
+ setTimeout(() => {
972
+ var _a, _b;
973
+ (_b = (_a = draft.props).onExpandedChange) == null ? void 0 : _b.call(_a, newExpanded);
974
+ });
967
975
  }
968
976
  }
969
977
  }, { runNow: true }), [state]);
@@ -975,7 +983,6 @@ function filterColumns(state) {
975
983
  }
976
984
  function syncSelections(state) {
977
985
  useEffect(() => state.addReaction((state2) => [state2.props.selectSyncChildren, state2.selection, state2.activeItems], ([selectSyncChildren, selection, activeItems], state2) => {
978
- var _a, _b;
979
986
  if (!selectSyncChildren)
980
987
  return;
981
988
  const newSelection = new Set(selection);
@@ -986,7 +993,10 @@ function syncSelections(state) {
986
993
  }
987
994
  if (newSelection.size !== selection.size) {
988
995
  state2.selection = newSelection;
989
- (_b = (_a = state2.props).onSelectionChange) == null ? void 0 : _b.call(_a, newSelection);
996
+ setTimeout(() => {
997
+ var _a, _b;
998
+ (_b = (_a = state2.props).onSelectionChange) == null ? void 0 : _b.call(_a, newSelection);
999
+ });
990
1000
  }
991
1001
  }, { runNow: true }), [state]);
992
1002
  }
@@ -1737,7 +1747,7 @@ function SortComponent({
1737
1747
  index: index2 >= 0 && state.sort.length > 1 ? index2 + 1 : void 0
1738
1748
  };
1739
1749
  });
1740
- function toggle2(e) {
1750
+ function toggle2(e, off) {
1741
1751
  const {
1742
1752
  props: {
1743
1753
  sort: controlledSort,
@@ -1745,16 +1755,21 @@ function SortComponent({
1745
1755
  }
1746
1756
  } = table.getState();
1747
1757
  const newDirection = direction === "asc" ? "desc" : "asc";
1748
- const newSort = (e.getModifierState("Control") ? table.getState().sort.filter((s) => s.columnId !== columnId) : []).concat({
1749
- columnId,
1750
- direction: newDirection
1751
- });
1758
+ const newSort = e.getModifierState("Control") || off ? table.getState().sort.filter((s) => s.columnId !== columnId) : [];
1759
+ if (!off) {
1760
+ newSort.push({
1761
+ columnId,
1762
+ direction: newDirection
1763
+ });
1764
+ }
1752
1765
  onSortChange == null ? void 0 : onSortChange(newSort);
1753
1766
  if (!controlledSort) {
1754
1767
  table.update((state) => {
1755
1768
  state.sort = newSort;
1756
1769
  });
1757
1770
  }
1771
+ e.preventDefault();
1772
+ return false;
1758
1773
  }
1759
1774
  return jsxs("div", {
1760
1775
  css: {
@@ -1768,7 +1783,8 @@ function SortComponent({
1768
1783
  textOverflow: "ellipsis"
1769
1784
  }
1770
1785
  },
1771
- onClick: toggle2,
1786
+ onClick: (e) => toggle2(e),
1787
+ onContextMenu: (e) => toggle2(e, true),
1772
1788
  children: [jsx("div", {
1773
1789
  children
1774
1790
  }), jsx(Badge, {
@@ -2012,10 +2028,10 @@ const TableInner = memo(function TableInner2({
2012
2028
  header: jsxs(Fragment, {
2013
2029
  children: [jsx("div", {
2014
2030
  className: classes == null ? void 0 : classes.headerCell,
2015
- css: [defaultClasses.headerFill, stickyHeader && defaultClasses.sticky]
2031
+ css: [defaultClasses.headerFill, stickyHeader && defaultClasses.sticky, stickyHeader instanceof Object && stickyHeader]
2016
2032
  }), jsxs("div", {
2017
2033
  className: classes == null ? void 0 : classes.headerCell,
2018
- css: [defaultClasses.headerCell, stickyHeader && defaultClasses.sticky],
2034
+ css: [defaultClasses.headerCell, stickyHeader && defaultClasses.sticky, stickyHeader instanceof Object && stickyHeader],
2019
2035
  children: [enableSelection && jsx(SelectComponent, {}), enableColumnSelection && jsx(ColumnSelection, {}), enableExport && jsx(Export, {}), jsx(ResizeHandleView, {})]
2020
2036
  }), jsx(ColumnHeaderContext.Provider, {
2021
2037
  children: activeColumns.map((column) => {
@@ -2024,7 +2040,7 @@ const TableInner = memo(function TableInner2({
2024
2040
  value: column.id,
2025
2041
  children: jsxs(ColumnHeader, {
2026
2042
  className: cx(classes == null ? void 0 : classes.headerCell, (_a2 = column.classes) == null ? void 0 : _a2.headerCell),
2027
- css: [defaultClasses.headerCell, columnStyleOverride.get(column.id), stickyHeader && defaultClasses.sticky],
2043
+ css: [defaultClasses.headerCell, columnStyleOverride.get(column.id), stickyHeader && defaultClasses.sticky, stickyHeader instanceof Object && stickyHeader],
2028
2044
  children: [jsx(SortComponent, {
2029
2045
  children: column.header
2030
2046
  }), jsx("div", {
@@ -2037,7 +2053,7 @@ const TableInner = memo(function TableInner2({
2037
2053
  })
2038
2054
  }), jsx("div", {
2039
2055
  className: classes == null ? void 0 : classes.headerCell,
2040
- css: [defaultClasses.headerFill, stickyHeader && defaultClasses.sticky]
2056
+ css: [defaultClasses.headerFill, stickyHeader && defaultClasses.sticky, stickyHeader instanceof Object && stickyHeader]
2041
2057
  })]
2042
2058
  }),
2043
2059
  children: (itemIds, startIndex) => itemIds.map((itemId, index) => jsx(Row, {