@omnigrid/react 0.1.23 → 0.1.24

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/OmniGrid.js CHANGED
@@ -1162,7 +1162,7 @@ export function OmniGrid({ className, style, slotComponents, ...options }) {
1162
1162
  */
1163
1163
  const renderHeader = (columns, originX, width, isPinned = false) => (_jsxs("div", { className: "omnigrid-header", style: {
1164
1164
  height: headerHeight,
1165
- overflow: "hidden",
1165
+ overflow: "visible",
1166
1166
  position: "sticky",
1167
1167
  top: 0,
1168
1168
  zIndex: isPinned ? 4 : 2,
@@ -1177,7 +1177,7 @@ export function OmniGrid({ className, style, slotComponents, ...options }) {
1177
1177
  }, children: renderGroupCells(depth, columns, originX) }, `group-row-${depth}`))), _jsx("div", { role: "row", className: "omnigrid-header-row", style: {
1178
1178
  height: rowHeight,
1179
1179
  left: 0,
1180
- overflow: hasGroups ? "visible" : "hidden",
1180
+ overflow: "visible",
1181
1181
  position: "absolute",
1182
1182
  top: headerRowCount * rowHeight,
1183
1183
  width: "100%",
@@ -74,6 +74,7 @@ export declare class PooledRowPane<T> {
74
74
  private originX;
75
75
  private variableHeight;
76
76
  private heightMeasureId;
77
+ private rowHasWrapText;
77
78
  constructor(host: HTMLDivElement, callbacks: PooledRowCallbacks<T>, bridge: ContentBridge<T>);
78
79
  /** Binds a row to the panel and fully rebuilds content. */
79
80
  bind(row: PooledRow<T>, columns: PooledColumn<T>[], originX?: number, spans?: RowSpanLayout | null): void;
@@ -102,6 +103,18 @@ export declare class PooledRowPane<T> {
102
103
  * height measurement.
103
104
  */
104
105
  resize(height: number): void;
106
+ /**
107
+ * Measures the natural content height of the bound row.
108
+ *
109
+ * The row node is sized to the (possibly stale) reserved row height with
110
+ * `overflow: hidden`, so reading `scrollHeight` on it clamps to that
111
+ * reserved height whenever the content fits inside it. That makes the
112
+ * measurement a one-way ratchet: rows grow when content overflows but can
113
+ * never shrink when a wider column needs fewer wrapped lines. Temporarily
114
+ * releasing the height constraint lets `scrollHeight` reflect the real
115
+ * (wrapped) content height in both directions.
116
+ */
117
+ private measureRowHeight;
105
118
  /** Moves an unused row far off-screen (outside viewport). */
106
119
  hide(): void;
107
120
  /** Clears content and unbinds the row, preserving DOM nodes. */
package/dist/pooledRow.js CHANGED
@@ -43,6 +43,7 @@ export class PooledRowPane {
43
43
  this.originX = 0;
44
44
  this.variableHeight = false;
45
45
  this.heightMeasureId = 0;
46
+ this.rowHasWrapText = false;
46
47
  host.classList.add("omnigrid-row");
47
48
  host.setAttribute("role", "row");
48
49
  host.style.position = "absolute";
@@ -79,12 +80,15 @@ export class PooledRowPane {
79
80
  const currentRow = this.row;
80
81
  if (!currentRow)
81
82
  return;
82
- const measured = host.scrollHeight;
83
+ // Non-wrap rows are single-line and keep the fixed rowHeight;
84
+ // only wrapText rows need the unconstrained natural-height
85
+ // measurement (see measureRowHeight).
86
+ const measured = this.rowHasWrapText ? this.measureRowHeight() : this.host.scrollHeight;
83
87
  if (Math.abs(measured - currentRow.height) < 1)
84
88
  return;
85
89
  this.callbacks.onRowHeightChange?.(currentRow.index, measured);
86
90
  });
87
- observer.observe(host);
91
+ observer.observe(this.host);
88
92
  }
89
93
  }
90
94
  /** Binds a row to the panel and fully rebuilds content. */
@@ -96,6 +100,7 @@ export class PooledRowPane {
96
100
  this.host.dataset.rowIndex = String(row.index);
97
101
  this.host.classList.remove("omnigrid-row-hover");
98
102
  this.originX = originX;
103
+ this.rowHasWrapText = columns.some((column) => column.column.wrapText);
99
104
  this.applyRowSizing(row);
100
105
  this.mapColumns(columns, true, spans);
101
106
  this.applyRowPresentation(row);
@@ -151,6 +156,31 @@ export class PooledRowPane {
151
156
  row.height = height;
152
157
  this.applyRowSizing(row);
153
158
  }
159
+ /**
160
+ * Measures the natural content height of the bound row.
161
+ *
162
+ * The row node is sized to the (possibly stale) reserved row height with
163
+ * `overflow: hidden`, so reading `scrollHeight` on it clamps to that
164
+ * reserved height whenever the content fits inside it. That makes the
165
+ * measurement a one-way ratchet: rows grow when content overflows but can
166
+ * never shrink when a wider column needs fewer wrapped lines. Temporarily
167
+ * releasing the height constraint lets `scrollHeight` reflect the real
168
+ * (wrapped) content height in both directions.
169
+ */
170
+ measureRowHeight() {
171
+ const host = this.host;
172
+ const prevHeight = host.style.height;
173
+ const prevMinHeight = host.style.minHeight;
174
+ const prevOverflow = host.style.overflow;
175
+ host.style.height = "auto";
176
+ host.style.minHeight = "";
177
+ host.style.overflow = "visible";
178
+ const measured = host.scrollHeight;
179
+ host.style.height = prevHeight;
180
+ host.style.minHeight = prevMinHeight;
181
+ host.style.overflow = prevOverflow;
182
+ return measured;
183
+ }
154
184
  /** Moves an unused row far off-screen (outside viewport). */
155
185
  hide() {
156
186
  this.host.style.transform = `translate3d(0, ${OFFSCREEN_Y}px, 0)`;
@@ -384,7 +414,7 @@ export class PooledRowPane {
384
414
  return;
385
415
  if (this.row?.index !== row.index)
386
416
  return;
387
- const measured = this.host.scrollHeight;
417
+ const measured = this.rowHasWrapText ? this.measureRowHeight() : this.host.scrollHeight;
388
418
  if (measured > 0 && Math.abs(measured - this.row.height) > 1) {
389
419
  this.callbacks.onRowHeightChange?.(this.row.index, measured);
390
420
  }
package/dist/useGrid.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { isColumnGroup } from '@omnigrid/core';
1
2
  import { Grid } from '@omnigrid/core';
2
3
  import { useCallback, useEffect, useRef, useSyncExternalStore } from 'react';
3
4
  /**
@@ -85,7 +86,51 @@ export function useGrid(options) {
85
86
  const next = options.columns ?? [];
86
87
  if (prev.length !== next.length || prev.some((column, index) => column !== next[index])) {
87
88
  lastSyncedColumnsRef.current = options.columns;
88
- grid.setColumns(options.columns);
89
+ // Merge the user's column definitions into the current (plugin-enriched)
90
+ // columns instead of replacing them wholesale. Plugins such as the resize
91
+ // plugin inject properties (e.g. `headerRenderer`) into columns that are
92
+ // not part of the user's column definitions; replacing columns with the
93
+ // raw definitions would strip them and break e.g. column resize handles.
94
+ const current = grid.getState().columns;
95
+ // Merge the user's column definitions INTO the current (plugin-enriched)
96
+ // columns instead of replacing them wholesale. Iterating over `current`
97
+ // preserves plugin-injected columns (e.g. the selection column prepended
98
+ // by SelectionPlugin) that have no corresponding entry in `options.columns`.
99
+ // Columns are matched by `id` (not by index) because plugin columns may be
100
+ // prepended/appended and shift positions. User column properties are merged
101
+ // on top; plugin-owned metadata that the user did not override is kept.
102
+ // User columns with no match in `current` are appended at the end.
103
+ const currentById = new Map();
104
+ current.forEach((column) => currentById.set(column.id, column));
105
+ const merged = [];
106
+ current.forEach((currentColumn) => {
107
+ const userColumn = next.find((c) => c.id === currentColumn.id);
108
+ if (!userColumn) {
109
+ merged.push(currentColumn);
110
+ return;
111
+ }
112
+ const enriched = { ...userColumn };
113
+ if (userColumn.headerRenderer === undefined && currentColumn.headerRenderer !== undefined) {
114
+ enriched.headerRenderer = currentColumn.headerRenderer;
115
+ }
116
+ if (!isColumnGroup(enriched) && !isColumnGroup(currentColumn) && !isColumnGroup(userColumn)) {
117
+ const leaf = enriched;
118
+ const currentLeaf = currentColumn;
119
+ const userLeaf = userColumn;
120
+ if (userLeaf.sortable === undefined)
121
+ leaf.sortable = currentLeaf.sortable;
122
+ if (userLeaf.sortState === undefined)
123
+ leaf.sortState = currentLeaf.sortState;
124
+ if (userLeaf.sortIndex === undefined)
125
+ leaf.sortIndex = currentLeaf.sortIndex;
126
+ }
127
+ merged.push(enriched);
128
+ });
129
+ next.forEach((userColumn) => {
130
+ if (!currentById.has(userColumn.id))
131
+ merged.push(userColumn);
132
+ });
133
+ grid.setColumns(merged);
89
134
  }
90
135
  }, [grid, options.columns]);
91
136
  // Controlled filter model: applied when the host passes a new reference.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omnigrid/react",
3
- "version": "0.1.23",
3
+ "version": "0.1.24",
4
4
  "description": "React adapter and renderer for OmniGrid",
5
5
  "keywords": [
6
6
  "omnigrid",