@omnigrid/react 0.1.4 → 0.1.6
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 +13 -3
- package/package.json +1 -1
package/dist/OmniGrid.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
2
|
+
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
3
3
|
import { DomPool } from "@omnigrid/core";
|
|
4
4
|
import { contentToReactNode } from "./content";
|
|
5
5
|
import { computeGroupSegments } from "./groupHeader";
|
|
@@ -91,7 +91,6 @@ export function OmniGrid({ className, style, slotComponents, ...options }) {
|
|
|
91
91
|
const renderContext = useMemo(() => ({ api: grid, state, slot: undefined }), [grid, state]);
|
|
92
92
|
const buildRenderContext = useCallback(() => renderContext, [renderContext]);
|
|
93
93
|
const autoHeight = style?.height === undefined;
|
|
94
|
-
const verticalScrollbarGutter = autoHeight ? "auto" : "stable";
|
|
95
94
|
const rowHeight = grid.getState().rowHeight;
|
|
96
95
|
// Column-group header stack: `headerRowCount` group rows (one per depth) above
|
|
97
96
|
// the leaf header row. Without groups `headerRowCount` is 0 and `columnGroupDepth`
|
|
@@ -114,6 +113,8 @@ export function OmniGrid({ className, style, slotComponents, ...options }) {
|
|
|
114
113
|
* group cell already sits directly above the leaf row.
|
|
115
114
|
*/
|
|
116
115
|
const measuredHeight = viewportData.totalHeight + headerHeight;
|
|
116
|
+
const hasVerticalOverflow = !autoHeight && measuredHeight > state.viewport.height;
|
|
117
|
+
const verticalScrollbarGutter = hasVerticalOverflow ? "stable" : "auto";
|
|
117
118
|
const viewportStyle = { ...style, height: autoHeight ? measuredHeight : style?.height };
|
|
118
119
|
const suppressRowHoverHighlight = options.suppressRowHoverHighlight ?? false;
|
|
119
120
|
const viewportClassName = ["omnigrid", className, suppressRowHoverHighlight ? "omnigrid-no-row-hover" : null].filter(Boolean).join(" ");
|
|
@@ -362,6 +363,13 @@ export function OmniGrid({ className, style, slotComponents, ...options }) {
|
|
|
362
363
|
measureViewport();
|
|
363
364
|
return () => observer.disconnect();
|
|
364
365
|
}, [grid, measureViewport]);
|
|
366
|
+
useLayoutEffect(() => {
|
|
367
|
+
if (!isMeasured || autoHeight)
|
|
368
|
+
return;
|
|
369
|
+
// Gutter changes alter clientWidth; sync it before paint so columns
|
|
370
|
+
// cannot render underneath a newly visible vertical scrollbar.
|
|
371
|
+
measureViewport();
|
|
372
|
+
}, [autoHeight, hasVerticalOverflow, isMeasured, measureViewport]);
|
|
365
373
|
/**
|
|
366
374
|
* Sync the DomPool after every structural re-render.
|
|
367
375
|
* This runs only when React actually re-renders (data / columns /
|
|
@@ -496,7 +504,9 @@ export function OmniGrid({ className, style, slotComponents, ...options }) {
|
|
|
496
504
|
}, children: item.column.headerRenderer ? (contentToReactNode(item.column.headerRenderer(item.column), {
|
|
497
505
|
registry: slotComponentsRef.current,
|
|
498
506
|
context: buildRenderContext,
|
|
499
|
-
})) : (_jsxs(_Fragment, { children: [_jsx("span", { className: "omnigrid-header-label", children: item.column.header ?? item.column.id }), _jsx("span", { className: "omnigrid-header-tools", children: item.column.sortState && (_jsx("span", { className: "omnigrid-sort-indicator", "aria-hidden": "true", children: item.column.sortState === "asc"
|
|
507
|
+
})) : (_jsxs(_Fragment, { children: [_jsx("span", { className: "omnigrid-header-label", children: item.column.header ?? item.column.id }), _jsx("span", { className: "omnigrid-header-tools", children: item.column.sortState && (_jsx("span", { className: "omnigrid-sort-indicator", "aria-hidden": "true", children: contentToReactNode(item.column.sortState === "asc"
|
|
508
|
+
? grid.icons.get("arrow-up")
|
|
509
|
+
: grid.icons.get("arrow-down"), { registry: slotComponentsRef.current, context: buildRenderContext }) })) })] })) }, item.column.id));
|
|
500
510
|
});
|
|
501
511
|
const renderGroupCells = (depth, columns, originX) => computeGroupSegments(viewportData.columnGroups, columns, depth, originX).map((segment, index) => (_jsx("div", { role: "columnheader", className: "omnigrid-header-cell omnigrid-header-group-cell", "aria-colspan": segment.columnCount, title: segment.group.header ?? segment.group.id, style: {
|
|
502
512
|
alignItems: "center",
|