reifyui 0.7.0 → 0.7.1

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.js CHANGED
@@ -2541,6 +2541,7 @@ function SheetGrid({
2541
2541
  rows.map((row, ri) => /* @__PURE__ */ jsxs12(
2542
2542
  "tr",
2543
2543
  {
2544
+ "data-row-id": row.id,
2544
2545
  style: {
2545
2546
  ...rowHeight(row) ? { height: rowHeight(row) } : null,
2546
2547
  "--shg-clamp": Math.max(1, Math.floor(((rowHeight(row) || 34) - 10) / 18))
@@ -2582,6 +2583,7 @@ function SheetGrid({
2582
2583
  return /* @__PURE__ */ jsxs12(
2583
2584
  "td",
2584
2585
  {
2586
+ "data-col-id": col.id,
2585
2587
  className: "shg-cell" + (computed ? " shg-cell-compute" : "") + (c.status && computed ? ` shg-cell-${c.status}` : "") + (peer ? " shg-cell-peer" : ""),
2586
2588
  style: peer ? { boxShadow: `inset 0 0 0 2px ${peer.color}` } : void 0,
2587
2589
  onClick: (e) => {
@@ -2842,6 +2844,21 @@ function ColumnMenu({ col, columns, anchor, columnTypes, renderColumnConfig, onA
2842
2844
  }
2843
2845
  );
2844
2846
  }
2847
+ function fitRowHeights(container, { rowIds, min = 34, max = 320, padding = 12 } = {}) {
2848
+ if (!container) return {};
2849
+ const out = {};
2850
+ const rows = container.querySelectorAll("tr[data-row-id]");
2851
+ for (const tr of rows) {
2852
+ const id = tr.getAttribute("data-row-id");
2853
+ if (rowIds && !rowIds.includes(id)) continue;
2854
+ let tallest = 0;
2855
+ for (const cell of tr.querySelectorAll("td[data-col-id] .shg-val")) {
2856
+ tallest = Math.max(tallest, cell.scrollHeight);
2857
+ }
2858
+ if (tallest) out[id] = Math.min(max, Math.max(min, Math.round(tallest + padding)));
2859
+ }
2860
+ return out;
2861
+ }
2845
2862
  function defaultCellText(cell) {
2846
2863
  const v = cell?.value;
2847
2864
  if (v == null) return "";
@@ -3640,6 +3657,7 @@ export {
3640
3657
  createResponsesDispatcher,
3641
3658
  extOf,
3642
3659
  fetchBalance,
3660
+ fitRowHeights,
3643
3661
  getSession,
3644
3662
  getToken,
3645
3663
  googleSignIn,