trotl-table 1.0.37 → 1.0.39

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
@@ -9644,6 +9644,7 @@ function TableInner({
9644
9644
  rowHeight = 34,
9645
9645
  groupHeaderHeight = 36,
9646
9646
  showKey = false,
9647
+ keyWidth = null,
9647
9648
  selectedRowsCallback = () => {},
9648
9649
  refreshTrigger = () => {},
9649
9650
  editCallback = () => {},
@@ -9911,9 +9912,34 @@ function TableInner({
9911
9912
  return dir === "asc" ? dx - dy : dy - dx;
9912
9913
  }
9913
9914
 
9914
- // Fallback string compare
9915
+ // Fallback string compare with numeric-prefix awareness
9915
9916
  const sx = String(x).toLowerCase();
9916
9917
  const sy = String(y).toLowerCase();
9918
+
9919
+ // helper to extract leading number and remainder
9920
+ const extractPrefix = str => {
9921
+ const m = str.match(/^(\d+)(.*)$/);
9922
+ if (m) return [Number(m[1]), m[2]];
9923
+ return null;
9924
+ };
9925
+ const px = extractPrefix(sx);
9926
+ const py = extractPrefix(sy);
9927
+ if (px && py) {
9928
+ // both have numeric prefix
9929
+ if (px[0] !== py[0]) {
9930
+ return dir === "asc" ? px[0] - py[0] : py[0] - px[0];
9931
+ }
9932
+ // same number, compare remainder lexicographically
9933
+ const restCmp = px[1].localeCompare(py[1]);
9934
+ return dir === "asc" ? restCmp : -restCmp;
9935
+ } else if (px && !py) {
9936
+ // number-prefixed should come before text-only
9937
+ return dir === "asc" ? -1 : 1;
9938
+ } else if (!px && py) {
9939
+ return dir === "asc" ? 1 : -1;
9940
+ }
9941
+
9942
+ // default lexicographic fall back
9917
9943
  if (sx < sy) return dir === "asc" ? -1 : 1;
9918
9944
  if (sx > sy) return dir === "asc" ? 1 : -1;
9919
9945
  return 0;
@@ -10369,7 +10395,12 @@ function TableInner({
10369
10395
  },
10370
10396
  onClick: e => e.stopPropagation()
10371
10397
  })), showKey && /*#__PURE__*/React.createElement("div", {
10372
- className: "table-cell key-cell"
10398
+ className: "table-cell key-cell",
10399
+ style: keyWidth ? {
10400
+ width: keyWidth,
10401
+ minWidth: keyWidth,
10402
+ maxWidth: keyWidth
10403
+ } : undefined
10373
10404
  }), /*#__PURE__*/React.createElement("div", {
10374
10405
  className: "table-cell group-header",
10375
10406
  style: {
@@ -10406,7 +10437,12 @@ function TableInner({
10406
10437
  },
10407
10438
  onClick: e => e.stopPropagation()
10408
10439
  })), showKey && /*#__PURE__*/React.createElement("div", {
10409
- className: "table-cell key-cell"
10440
+ className: "table-cell key-cell",
10441
+ style: keyWidth ? {
10442
+ width: keyWidth,
10443
+ minWidth: keyWidth,
10444
+ maxWidth: keyWidth
10445
+ } : undefined
10410
10446
  }), /*#__PURE__*/React.createElement("div", {
10411
10447
  className: "table-cell group-header"
10412
10448
  }, item.expanded ? "▾" : "▸", " ", translate(item.groupName), " (", item.rowCount, ")"), columns.slice(1).map((_, i) => /*#__PURE__*/React.createElement("div", {
@@ -10444,7 +10480,12 @@ function TableInner({
10444
10480
  onChange: () => toggleRowSelection(row.id)
10445
10481
  })), showKey && /*#__PURE__*/React.createElement("div", {
10446
10482
  title: visualIndex,
10447
- className: "table-cell key-cell"
10483
+ className: "table-cell key-cell",
10484
+ style: keyWidth ? {
10485
+ width: keyWidth,
10486
+ minWidth: keyWidth,
10487
+ maxWidth: keyWidth
10488
+ } : undefined
10448
10489
  }, visualIndex), allColumns.map((col, i) => {
10449
10490
  let cellStyle = col.style ? {
10450
10491
  ...col.style
@@ -10605,7 +10646,12 @@ function TableInner({
10605
10646
  }
10606
10647
  }
10607
10648
  })), showKey && /*#__PURE__*/React.createElement("div", {
10608
- className: "table-cell key-cell"
10649
+ className: "table-cell key-cell",
10650
+ style: keyWidth ? {
10651
+ width: keyWidth,
10652
+ minWidth: keyWidth,
10653
+ maxWidth: keyWidth
10654
+ } : undefined
10609
10655
  }, "#"), allColumns.map((col, i) => {
10610
10656
  let cellStyle = col.style ? {
10611
10657
  ...col.style,
@@ -10618,15 +10664,18 @@ function TableInner({
10618
10664
  cellStyle.maxWidth = col.style.width;
10619
10665
  cellStyle.width = col.style.width;
10620
10666
  }
10667
+ // determine header title text for tooltip; custom columns may also have string headers
10668
+ const headerTitle = typeof col.header === 'string' ? col.header : undefined;
10621
10669
  return /*#__PURE__*/React.createElement("div", {
10622
10670
  key: i,
10623
10671
  className: "table-cell",
10624
10672
  style: cellStyle,
10625
- title: typeof col.header === 'string' ? col.header : undefined,
10673
+ title: headerTitle,
10626
10674
  onClick: col.isCustom ? undefined : () => setSort(col.accessor)
10627
10675
  }, col.isCustom ? col.header ?? '' : col.header, !col.isCustom && sorting?.column === col.accessor && (sorting.direction === "asc" ? " ↑" : " ↓"));
10628
10676
  }), showActions && /*#__PURE__*/React.createElement("div", {
10629
- className: "table-cell action-cell"
10677
+ className: "table-cell action-cell",
10678
+ title: translate("action")
10630
10679
  }, showIcons ? /*#__PURE__*/React.createElement("span", {
10631
10680
  title: translate("action")
10632
10681
  }, "\u2699\uFE0F") : translate("action")))), /*#__PURE__*/React.createElement("div", {