schummar-table 0.51.3 → 0.51.5

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
@@ -2901,8 +2901,11 @@ function filterColumns(state) {
2901
2901
  ], ([columns, hiddenColumns, columnOrder, displaySize], draft) => {
2902
2902
  draft.activeColumns = orderBy(columns.filter((column) => !(column.hidden ?? hiddenColumns.has(column.id))), [(column) => columnOrder.indexOf(column.id)]);
2903
2903
  draft.visibleColumns = draft.activeColumns.filter((column) => displaySize === void 0 || column.displaySize === void 0 || column.displaySize.includes(displaySize));
2904
- draft.rowHeights.clear();
2905
2904
  }, { runNow: true }), [state]);
2905
+ (0, react.useEffect)(() => state.addReaction((state$1) => new Set(state$1.visibleColumns.map((column) => column.id)), (_, draft) => {
2906
+ draft.rowHeights.clear();
2907
+ draft.rowHeightsKey = Math.random();
2908
+ }, { runNow: false }), [state]);
2906
2909
  }
2907
2910
 
2908
2911
  //#endregion
@@ -3009,6 +3012,7 @@ function useTableState(_props) {
3009
3012
  selection: props.defaultSelection ?? /* @__PURE__ */ new Set(),
3010
3013
  expanded: props.defaultExpanded ?? /* @__PURE__ */ new Set(),
3011
3014
  rowHeights: /* @__PURE__ */ new Map(),
3015
+ rowHeightsKey: Math.random(),
3012
3016
  filters: /* @__PURE__ */ new Map(),
3013
3017
  filterValues: /* @__PURE__ */ new Map(),
3014
3018
  hiddenColumns: props.defaultHiddenColumns ?? /* @__PURE__ */ new Set(),
@@ -3476,9 +3480,14 @@ function Export() {
3476
3480
  });
3477
3481
  const [anchor, setAnchor] = (0, react.useState)(null);
3478
3482
  function execute({ action, exporter }) {
3479
- const { activeColumns, activeItems, items } = table.getState();
3483
+ const { activeColumns, activeItems, selection, items } = table.getState();
3480
3484
  const columns = activeColumns.map((column) => column.exportHeader);
3481
- const rows = (all ? items : activeItems).map((item) => activeColumns.map((column) => column.exportCell(column.value(item.value), item.value)));
3485
+ let exportedItems = items;
3486
+ if (!all) {
3487
+ exportedItems = activeItems;
3488
+ if (selection.size > 0) exportedItems = exportedItems.filter((item) => selection.has(item.id));
3489
+ }
3490
+ const rows = exportedItems.map((item) => activeColumns.map((column) => column.exportCell(column.value(item.value), item.value)));
3482
3491
  if (action === "copy") {
3483
3492
  const data = exporter.exportToString(columns, rows);
3484
3493
  navigator.clipboard.writeText(data);
@@ -3697,7 +3706,7 @@ function SelectComponent({ itemId }) {
3697
3706
 
3698
3707
  //#endregion
3699
3708
  //#region src/components/row.tsx
3700
- const Row = (0, react.memo)(function Row$1({ itemId, rowIndex }) {
3709
+ const Row = (0, react.memo)(function Row$1({ itemId, rowIndex, rowHeightsKey }) {
3701
3710
  const table = useTableContext();
3702
3711
  const divRef = (0, react.useRef)(null);
3703
3712
  const detailsDivRef = (0, react.useRef)(null);
@@ -3744,7 +3753,8 @@ const Row = (0, react.memo)(function Row$1({ itemId, rowIndex }) {
3744
3753
  table,
3745
3754
  itemId,
3746
3755
  divRef.current,
3747
- detailsDivRef.current
3756
+ detailsDivRef.current,
3757
+ rowHeightsKey
3748
3758
  ]);
3749
3759
  (0, react.useLayoutEffect)(() => {
3750
3760
  table.getState().props.debugRender?.("render row", itemId);
@@ -3949,6 +3959,7 @@ const TableInner = (0, react.memo)(function TableInner$1({ hidden }) {
3949
3959
  const enableColumnSelection = table.useState((state) => state.props.enableColumnSelection);
3950
3960
  const enableExport = table.useState((state) => state.props.enableExport);
3951
3961
  const cssVariables = useCssVariables();
3962
+ const rowHeightsKey = table.useState((state) => state.rowHeightsKey);
3952
3963
  const enableClearFiltersButton = table.useState((state) => state.props.enableClearFiltersButton);
3953
3964
  (0, react.useLayoutEffect)(() => {
3954
3965
  table.getState().props.debugRender?.("render table inner");
@@ -4054,7 +4065,8 @@ const TableInner = (0, react.memo)(function TableInner$1({ hidden }) {
4054
4065
  ] })] }),
4055
4066
  children: (itemIds, startIndex) => itemIds.map((itemId, index) => /* @__PURE__ */ (0, __emotion_react_jsx_runtime.jsx)(Row, {
4056
4067
  itemId,
4057
- rowIndex: startIndex + index
4068
+ rowIndex: startIndex + index,
4069
+ rowHeightsKey
4058
4070
  }, itemId))
4059
4071
  });
4060
4072
  });