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.cjs CHANGED
@@ -95,6 +95,7 @@ __export(src_exports, {
95
95
  createResponsesDispatcher: () => createResponsesDispatcher,
96
96
  extOf: () => extOf,
97
97
  fetchBalance: () => fetchBalance,
98
+ fitRowHeights: () => fitRowHeights,
98
99
  getSession: () => getSession,
99
100
  getToken: () => getToken,
100
101
  googleSignIn: () => googleSignIn,
@@ -2768,6 +2769,7 @@ function SheetGrid({
2768
2769
  rows.map((row, ri) => /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
2769
2770
  "tr",
2770
2771
  {
2772
+ "data-row-id": row.id,
2771
2773
  style: {
2772
2774
  ...rowHeight(row) ? { height: rowHeight(row) } : null,
2773
2775
  "--shg-clamp": Math.max(1, Math.floor(((rowHeight(row) || 34) - 10) / 18))
@@ -2809,6 +2811,7 @@ function SheetGrid({
2809
2811
  return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
2810
2812
  "td",
2811
2813
  {
2814
+ "data-col-id": col.id,
2812
2815
  className: "shg-cell" + (computed ? " shg-cell-compute" : "") + (c.status && computed ? ` shg-cell-${c.status}` : "") + (peer ? " shg-cell-peer" : ""),
2813
2816
  style: peer ? { boxShadow: `inset 0 0 0 2px ${peer.color}` } : void 0,
2814
2817
  onClick: (e) => {
@@ -3069,6 +3072,21 @@ function ColumnMenu({ col, columns, anchor, columnTypes, renderColumnConfig, onA
3069
3072
  }
3070
3073
  );
3071
3074
  }
3075
+ function fitRowHeights(container, { rowIds, min = 34, max = 320, padding = 12 } = {}) {
3076
+ if (!container) return {};
3077
+ const out = {};
3078
+ const rows = container.querySelectorAll("tr[data-row-id]");
3079
+ for (const tr of rows) {
3080
+ const id = tr.getAttribute("data-row-id");
3081
+ if (rowIds && !rowIds.includes(id)) continue;
3082
+ let tallest = 0;
3083
+ for (const cell of tr.querySelectorAll("td[data-col-id] .shg-val")) {
3084
+ tallest = Math.max(tallest, cell.scrollHeight);
3085
+ }
3086
+ if (tallest) out[id] = Math.min(max, Math.max(min, Math.round(tallest + padding)));
3087
+ }
3088
+ return out;
3089
+ }
3072
3090
  function defaultCellText(cell) {
3073
3091
  const v = cell?.value;
3074
3092
  if (v == null) return "";