trotl-table 1.0.44 → 1.0.46

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/Table.cjs.js CHANGED
@@ -9700,6 +9700,8 @@ function TableInner({
9700
9700
  };
9701
9701
  }
9702
9702
 
9703
+ // normalize delete modal flag early (handles string 'false' etc)
9704
+ const skipDeleteModal = disableDeleteModal === true;
9703
9705
  // Use refs for callbacks to prevent infinite loops from dependency changes
9704
9706
  const selectedRowsCallbackRef = React.useRef(selectedRowsCallback);
9705
9707
  const refreshTriggerRef = React.useRef(refreshTrigger);
@@ -10075,7 +10077,7 @@ function TableInner({
10075
10077
  const [pendingDelete, setPendingDelete] = React.useState(null);
10076
10078
 
10077
10079
  // perform deletion for a given row (shared by immediate & modal-confirm flows)
10078
- const doDelete = async row => {
10080
+ const doDelete = React.useCallback(async row => {
10079
10081
  if (!row) return;
10080
10082
 
10081
10083
  // call callback if provided; only abort deletion if it explicitly
@@ -10100,7 +10102,7 @@ function TableInner({
10100
10102
  }
10101
10103
  });
10102
10104
  refreshTriggerRef.current?.();
10103
- };
10105
+ }, [deleteCallbackRef, isGrouped, refreshTriggerRef]);
10104
10106
  const confirmDelete = async () => {
10105
10107
  if (!pendingDelete) return;
10106
10108
  await doDelete(pendingDelete);
@@ -10242,7 +10244,7 @@ function TableInner({
10242
10244
  }
10243
10245
  // existing highlight logic for other fields
10244
10246
  return highlight(String(v));
10245
- }, [highlight]);
10247
+ }, [highlight, isGrouped]);
10246
10248
  const showView = buttons.includes("view");
10247
10249
  const showEdit = buttons.includes("edit");
10248
10250
  const showDelete = buttons.includes("delete");
@@ -10340,7 +10342,7 @@ function TableInner({
10340
10342
  }, [tableDataFlat, isGrouped, groupKey]);
10341
10343
 
10342
10344
  // DUPLICATE
10343
- const doDuplicate = row => {
10345
+ const doDuplicate = React.useCallback(row => {
10344
10346
  if (!row) return;
10345
10347
  // try user callback first; if it returns an object with newRow use that
10346
10348
  let newRow = null;
@@ -10381,7 +10383,7 @@ function TableInner({
10381
10383
  return [...(prev || []), newRow];
10382
10384
  });
10383
10385
  refreshTriggerRef.current?.();
10384
- };
10386
+ }, [duplicateCallbackRef, isGrouped, groupKey, refreshTriggerRef]);
10385
10387
 
10386
10388
  // ROW RENDERER
10387
10389
  const rowRenderer = React.useCallback(({
@@ -10594,12 +10596,14 @@ function TableInner({
10594
10596
  }, "\u270F\uFE0F") : translate("edit")), showDuplicate && /*#__PURE__*/React.createElement("button", {
10595
10597
  className: "action-btn-table",
10596
10598
  onClick: e => {
10597
- // e.stopPropagation();
10599
+ e.stopPropagation();
10598
10600
  // always duplicate locally; user callback may also return newRow
10599
10601
  doDuplicate(row);
10600
10602
  try {
10601
10603
  duplicateCallbackRef.current(row);
10602
- } catch {}
10604
+ } catch (err) {
10605
+ console.error(err);
10606
+ }
10603
10607
  },
10604
10608
  onDoubleClick: e => e.stopPropagation(),
10605
10609
  "aria-label": translate("duplicate")
@@ -10613,9 +10617,10 @@ function TableInner({
10613
10617
  }, "\uD83D\uDDD0") : translate("duplicate")), showDelete && /*#__PURE__*/React.createElement("button", {
10614
10618
  className: "action-btn-table",
10615
10619
  onClick: e => {
10616
- // e.stopPropagation();
10620
+ // stop propagation so parent row handlers don't interfere
10621
+ e.stopPropagation();
10617
10622
  // If prop set, skip integrated confirmation modal and delete immediately
10618
- if (disableDeleteModal) {
10623
+ if (skipDeleteModal) {
10619
10624
  doDelete(row);
10620
10625
  return;
10621
10626
  }
@@ -10631,7 +10636,7 @@ function TableInner({
10631
10636
  }, "\uD83D\uDDD1\uFE0F") : translate("delete")), showShare && /*#__PURE__*/React.createElement("button", {
10632
10637
  className: "action-btn-table",
10633
10638
  onClick: e => {
10634
- // e.stopPropagation();
10639
+ e.stopPropagation();
10635
10640
  shareCallbackRef.current(row);
10636
10641
  },
10637
10642
  onDoubleClick: e => e.stopPropagation(),
@@ -10653,7 +10658,7 @@ function TableInner({
10653
10658
  }, content);
10654
10659
  }
10655
10660
  return content;
10656
- }, [tableDataFlat, columns, selectedRows, toggleRowSelection, groupRowsById, renderCell, showActions, showDelete, showEdit, showKey, showView, translate, enableDragRow, moveRow, enableMultiSelect, rowHeight, tableId, customColumns, doubleClickEnable]);
10661
+ }, [tableDataFlat, columns, selectedRows, toggleRowSelection, groupRowsById, renderCell, showActions, showDelete, showEdit, showKey, showView, translate, enableDragRow, moveRow, enableMultiSelect, rowHeight, tableId, customColumns, doubleClickEnable, doDelete, doDuplicate, keyWidth, showDuplicate, showIcons, showShare, skipDeleteModal]);
10657
10662
  const rowHeightGetter = ({
10658
10663
  index
10659
10664
  }) => tableDataFlat[index]?.type === "group" ? groupHeaderHeight : rowHeight;