@omnigrid/react 0.1.8 → 0.1.10
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/README.md +37 -37
- package/dist/OmniGrid.js +23 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
# @omnigrid/react
|
|
2
|
-
|
|
3
|
-
React adapter and renderer for OmniGrid. Renders the headless core engine into the DOM using React.
|
|
4
|
-
|
|
5
|
-
## What it provides
|
|
6
|
-
|
|
7
|
-
- **`<OmniGrid />`** — React component that accepts `GridOptions` and renders a fully virtualized, 2D scrolled data grid
|
|
8
|
-
- **`useGrid()`** — hook that creates and manages a `GridCore` instance with full lifecycle handling
|
|
9
|
-
- **Cell / Row pooling** — reusable React content via DOM-pool integration for minimal re-renders
|
|
10
|
-
- **Styles and default theme** — required structural styles and light/dark default colors are included automatically
|
|
11
|
-
- **`transpilePackages`-ready** — works out of the box with Next.js and other bundlers
|
|
12
|
-
|
|
13
|
-
## Usage
|
|
14
|
-
|
|
15
|
-
```tsx
|
|
16
|
-
import { OmniGrid } from "@omnigrid/react";
|
|
17
|
-
import { useMemo } from "react";
|
|
18
|
-
|
|
19
|
-
const columns = useMemo(() => [...], []);
|
|
20
|
-
const data = [...];
|
|
21
|
-
|
|
22
|
-
<OmniGrid columns={columns} data={data} />;
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
To customize the table's color style, install a compatible `@omnigrid/*-theme`
|
|
26
|
-
package and import it in the application after `@omnigrid/react`. Theme packages
|
|
27
|
-
include their own light and dark variants; they are not light/dark mode toggles.
|
|
28
|
-
|
|
29
|
-
## Links
|
|
30
|
-
|
|
31
|
-
- **Source:** https://github.com/KRZK-Apps/omnigrid/tree/main/adapters/react
|
|
32
|
-
- **Demo:** https://omnigrid-demo.vercel.app/
|
|
33
|
-
- **Issues:** https://github.com/KRZK-Apps/omnigrid/issues
|
|
34
|
-
|
|
35
|
-
## License
|
|
36
|
-
|
|
37
|
-
MIT © KRZK Apps
|
|
1
|
+
# @omnigrid/react
|
|
2
|
+
|
|
3
|
+
React adapter and renderer for OmniGrid. Renders the headless core engine into the DOM using React.
|
|
4
|
+
|
|
5
|
+
## What it provides
|
|
6
|
+
|
|
7
|
+
- **`<OmniGrid />`** — React component that accepts `GridOptions` and renders a fully virtualized, 2D scrolled data grid
|
|
8
|
+
- **`useGrid()`** — hook that creates and manages a `GridCore` instance with full lifecycle handling
|
|
9
|
+
- **Cell / Row pooling** — reusable React content via DOM-pool integration for minimal re-renders
|
|
10
|
+
- **Styles and default theme** — required structural styles and light/dark default colors are included automatically
|
|
11
|
+
- **`transpilePackages`-ready** — works out of the box with Next.js and other bundlers
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
import { OmniGrid } from "@omnigrid/react";
|
|
17
|
+
import { useMemo } from "react";
|
|
18
|
+
|
|
19
|
+
const columns = useMemo(() => [...], []);
|
|
20
|
+
const data = [...];
|
|
21
|
+
|
|
22
|
+
<OmniGrid columns={columns} data={data} />;
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
To customize the table's color style, install a compatible `@omnigrid/*-theme`
|
|
26
|
+
package and import it in the application after `@omnigrid/react`. Theme packages
|
|
27
|
+
include their own light and dark variants; they are not light/dark mode toggles.
|
|
28
|
+
|
|
29
|
+
## Links
|
|
30
|
+
|
|
31
|
+
- **Source:** https://github.com/KRZK-Apps/omnigrid/tree/main/adapters/react
|
|
32
|
+
- **Demo:** https://omnigrid-demo.vercel.app/
|
|
33
|
+
- **Issues:** https://github.com/KRZK-Apps/omnigrid/issues
|
|
34
|
+
|
|
35
|
+
## License
|
|
36
|
+
|
|
37
|
+
MIT © KRZK Apps
|
package/dist/OmniGrid.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
3
|
+
import { flushSync } from "react-dom";
|
|
3
4
|
import { DomPool } from "@omnigrid/core";
|
|
4
5
|
import { contentToReactNode } from "./content";
|
|
5
6
|
import { computeGroupSegments } from "./groupHeader";
|
|
@@ -285,7 +286,7 @@ export function OmniGrid({ className, style, slotComponents, ...options }) {
|
|
|
285
286
|
* React effects (structural changes) and directly from the scroll rAF
|
|
286
287
|
* handler (imperative, no React re-render).
|
|
287
288
|
*/
|
|
288
|
-
const syncPool = () => {
|
|
289
|
+
const syncPool = (synchronousColumnWindow = false) => {
|
|
289
290
|
const state = grid.getState();
|
|
290
291
|
const currentViewportData = grid.getViewportData();
|
|
291
292
|
const pinnedLeftWidth = currentViewportData.pinnedLeftColumns.reduce((sum, item) => sum + item.width, 0);
|
|
@@ -314,9 +315,19 @@ export function OmniGrid({ className, style, slotComponents, ...options }) {
|
|
|
314
315
|
const columnWindowKey = `${currentViewportData.columnRange.start}:${currentViewportData.columnRange.end}:${state.viewport.width}:${pinnedLeftWidth}:${pinnedRightWidth}`;
|
|
315
316
|
if (columnWindowKey !== columnWindowKeyRef.current) {
|
|
316
317
|
columnWindowKeyRef.current = columnWindowKey;
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
318
|
+
const updateColumnWindow = () => {
|
|
319
|
+
for (const pane of layers.central.panes)
|
|
320
|
+
pane.updateColumns(layers.central.columns, layers.central.originX);
|
|
321
|
+
setColumnWindowVersion((v) => v + 1);
|
|
322
|
+
};
|
|
323
|
+
if (synchronousColumnWindow) {
|
|
324
|
+
// Keep React-rendered cell content and headers in step with the
|
|
325
|
+
// imperative cell repositioning before the browser paints.
|
|
326
|
+
flushSync(updateColumnWindow);
|
|
327
|
+
}
|
|
328
|
+
else {
|
|
329
|
+
updateColumnWindow();
|
|
330
|
+
}
|
|
320
331
|
}
|
|
321
332
|
};
|
|
322
333
|
/**
|
|
@@ -432,9 +443,14 @@ export function OmniGrid({ className, style, slotComponents, ...options }) {
|
|
|
432
443
|
const scrollLeft = element ? element.scrollLeft : frame.left;
|
|
433
444
|
// setViewport with scroll-only updates does NOT notify the Store,
|
|
434
445
|
// so this does NOT trigger a React re-render. The DomPool is
|
|
435
|
-
// updated imperatively below
|
|
436
|
-
|
|
437
|
-
|
|
446
|
+
// updated imperatively below, and both the row-column rebind and the
|
|
447
|
+
// header window update must flush in the same React paint to avoid
|
|
448
|
+
// one-frame horizontal/vertical jumps when custom cell renderers are
|
|
449
|
+
// mounted into pooled DOM nodes.
|
|
450
|
+
flushSync(() => {
|
|
451
|
+
grid.setViewport({ scrollTop, scrollLeft });
|
|
452
|
+
syncPool(true);
|
|
453
|
+
});
|
|
438
454
|
});
|
|
439
455
|
};
|
|
440
456
|
if (!isMeasured) {
|