@omnigrid/react 0.1.30 → 0.1.31
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 +66 -62
- package/dist/OmniGrid.js +137 -45
- package/dist/cellTooltip.d.ts +6 -2
- package/dist/cellTooltip.js +38 -8
- package/dist/index.d.ts +2 -2
- package/dist/pooledRow.js +1 -0
- package/dist/popup.d.ts +1 -0
- package/dist/popup.js +18 -9
- package/dist/reactColumnDef.d.ts +30 -0
- package/dist/types.d.ts +8 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,62 +1,66 @@
|
|
|
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
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
scrolling
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
<
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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
|
+
Column `headerRenderer` callbacks provide the header's primary content. The adapter owns the
|
|
26
|
+
shared header layout and keeps sorting, filtering, and registered plugin extensions alongside it,
|
|
27
|
+
so plugins can add controls without replacing or duplicating the header renderer.
|
|
28
|
+
|
|
29
|
+
## Overlays
|
|
30
|
+
|
|
31
|
+
Automatic loading, no-rows, and no-matching-rows overlays cover the body below the sticky
|
|
32
|
+
header. They hide vertical scrolling while preserving its gutter, so columns do not shift;
|
|
33
|
+
horizontal scrolling remains available. Automatic error overlays cover the full grid.
|
|
34
|
+
Any active overlay hides vertical scrolling and preserves its gutter, regardless of scope.
|
|
35
|
+
Manual overlays default to body-only, except errors default to full-grid; set `scope` to
|
|
36
|
+
`"bodyOnly"` or `"full"` to choose the placement. `blockScroll: true` locks horizontal
|
|
37
|
+
scrolling; vertical scrolling is always locked while an overlay is active.
|
|
38
|
+
|
|
39
|
+
```tsx
|
|
40
|
+
import { OmniGrid, type OverlayComponentProps } from "@omnigrid/react";
|
|
41
|
+
|
|
42
|
+
function LoadError<T>({ message }: OverlayComponentProps<T>) {
|
|
43
|
+
return <div role="alert">{message ?? "Unable to load rows"}</div>;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
<OmniGrid
|
|
47
|
+
columns={columns}
|
|
48
|
+
data={data}
|
|
49
|
+
overlayComponents={{ error: LoadError }}
|
|
50
|
+
onGridReady={(grid) => grid.showOverlay({ type: "error", message: "Please retry" })}
|
|
51
|
+
/>;
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
To customize the table's color style, install a compatible `@omnigrid/*-theme`
|
|
55
|
+
package and import it in the application after `@omnigrid/react`. Theme packages
|
|
56
|
+
include their own light and dark variants; they are not light/dark mode toggles.
|
|
57
|
+
|
|
58
|
+
## Links
|
|
59
|
+
|
|
60
|
+
- **Source:** https://github.com/KRZK-Apps/omnigrid/tree/main/adapters/react
|
|
61
|
+
- **Demo:** https://omnigrid-demo.vercel.app/
|
|
62
|
+
- **Issues:** https://github.com/KRZK-Apps/omnigrid/issues
|
|
63
|
+
|
|
64
|
+
## License
|
|
65
|
+
|
|
66
|
+
MIT © KRZK Apps
|
package/dist/OmniGrid.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { createElement, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, } from "react";
|
|
3
3
|
import { flushSync } from "react-dom";
|
|
4
|
-
import { DomPool, isActiveCondition } from "@omnigrid/core";
|
|
5
|
-
import { contentToReactNode, hasRenderableContent } from "./content";
|
|
4
|
+
import { DomPool, flattenColumns, isActiveCondition } from "@omnigrid/core";
|
|
6
5
|
import { CellTooltipLayer } from "./cellTooltip";
|
|
6
|
+
import { contentToReactNode, hasRenderableContent } from "./content";
|
|
7
|
+
import { getCollapsedGroupDisplay, getGroupColumnRole, isGroupRowNode, poolGetRowId, renderGroupCellContent, renderGroupCellPlaceholder, } from "./groupCell";
|
|
7
8
|
import { computeGroupSegments } from "./groupHeader";
|
|
8
|
-
import { getCollapsedGroupDisplay, getGroupColumnRole, isGroupRowNode, poolGetRowId, renderGroupCellContent, renderGroupCellPlaceholder } from "./groupCell";
|
|
9
|
-
import { getRowRenderParams } from "./rowRenderParams";
|
|
10
|
-
import { PooledRowPane } from "./pooledRow";
|
|
11
|
-
import { createCellRoot } from "./reactRoot";
|
|
12
9
|
import { renderDefaultOverlay } from "./overlays";
|
|
10
|
+
import { PooledRowPane } from "./pooledRow";
|
|
13
11
|
import { PopupHost } from "./popup";
|
|
12
|
+
import { createCellRoot } from "./reactRoot";
|
|
13
|
+
import { getRowRenderParams } from "./rowRenderParams";
|
|
14
14
|
import { resolveCellClasses, resolveCellStyle, resolveColumnPresentation, resolveGroupHeaderClasses, resolveGroupHeaderStyle, resolveHeaderClasses, resolveHeaderStyle, } from "./styling";
|
|
15
15
|
import { useGrid } from "./useGrid";
|
|
16
16
|
function getCellValue(row, column) {
|
|
@@ -81,6 +81,20 @@ function createRowLayerState() {
|
|
|
81
81
|
*/
|
|
82
82
|
export function OmniGrid({ className, style, slotComponents, cellTooltipRenderer, cellTooltipClassName, ...options }) {
|
|
83
83
|
const { grid, state, viewportData } = useGrid(options);
|
|
84
|
+
const columnTooltipOptions = useMemo(() => {
|
|
85
|
+
const result = new Map();
|
|
86
|
+
for (const column of flattenColumns(state.columns)) {
|
|
87
|
+
const columnWithTooltip = column;
|
|
88
|
+
if (columnWithTooltip.cellTooltipRenderer !== undefined ||
|
|
89
|
+
columnWithTooltip.cellTooltipClassName !== undefined) {
|
|
90
|
+
result.set(column.id, {
|
|
91
|
+
renderer: columnWithTooltip.cellTooltipRenderer,
|
|
92
|
+
className: columnWithTooltip.cellTooltipClassName,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return result;
|
|
97
|
+
}, [state.columns]);
|
|
84
98
|
const viewportRef = useRef(null);
|
|
85
99
|
const layoutRef = useRef(null);
|
|
86
100
|
/** Scrollable content wrapper — its height is the total height of all rows. */
|
|
@@ -234,7 +248,9 @@ export function OmniGrid({ className, style, slotComponents, cellTooltipRenderer
|
|
|
234
248
|
height: autoHeight ? measuredHeight : style?.height,
|
|
235
249
|
...(cellFlashDurationMs !== false ? { "--omnigrid-flash-duration": `${cellFlashDurationMs}ms` } : {}),
|
|
236
250
|
};
|
|
237
|
-
const viewportClassName = ["omnigrid", className, suppressRowHoverHighlight ? "omnigrid-no-row-hover" : null]
|
|
251
|
+
const viewportClassName = ["omnigrid", className, suppressRowHoverHighlight ? "omnigrid-no-row-hover" : null]
|
|
252
|
+
.filter(Boolean)
|
|
253
|
+
.join(" ");
|
|
238
254
|
const overlayState = state.overlay;
|
|
239
255
|
const filterModelSnapshot = grid.getFilterModel();
|
|
240
256
|
const isColumnFiltered = (column) => {
|
|
@@ -546,9 +562,17 @@ export function OmniGrid({ className, style, slotComponents, cellTooltipRenderer
|
|
|
546
562
|
// show the grouping field's value in the group column instead of
|
|
547
563
|
// the row's own field value.
|
|
548
564
|
const collapsedGroupDisplay = getCollapsedGroupDisplay(info.data, info.column, grid.getState().groupBy ?? [], grid.getState().groupColumnMode ?? "single");
|
|
549
|
-
const value = collapsedGroupDisplay !== undefined
|
|
565
|
+
const value = collapsedGroupDisplay !== undefined
|
|
566
|
+
? collapsedGroupDisplay.value
|
|
567
|
+
: getCellValue(rawData, info.column);
|
|
550
568
|
const content = info.column.cellRenderer
|
|
551
|
-
? info.column.cellRenderer({
|
|
569
|
+
? info.column.cellRenderer({
|
|
570
|
+
value,
|
|
571
|
+
data: rawData,
|
|
572
|
+
column: info.column,
|
|
573
|
+
id: info.rowId,
|
|
574
|
+
index: info.rowIndex,
|
|
575
|
+
})
|
|
552
576
|
: info.column.valueFormatter
|
|
553
577
|
? info.column.valueFormatter(value)
|
|
554
578
|
: String(value ?? "");
|
|
@@ -575,7 +599,9 @@ export function OmniGrid({ className, style, slotComponents, cellTooltipRenderer
|
|
|
575
599
|
? info.data.data
|
|
576
600
|
: info.data);
|
|
577
601
|
const collapsedGroupDisplay = getCollapsedGroupDisplay(info.data, info.column, grid.getState().groupBy ?? [], grid.getState().groupColumnMode ?? "single");
|
|
578
|
-
const value = collapsedGroupDisplay !== undefined
|
|
602
|
+
const value = collapsedGroupDisplay !== undefined
|
|
603
|
+
? collapsedGroupDisplay.value
|
|
604
|
+
: getCellValue(rawData, info.column);
|
|
579
605
|
if (info.column.valueFormatter)
|
|
580
606
|
return info.column.valueFormatter(value);
|
|
581
607
|
const valueType = typeof value;
|
|
@@ -588,7 +614,9 @@ export function OmniGrid({ className, style, slotComponents, cellTooltipRenderer
|
|
|
588
614
|
const base = isGroup ? "omnigrid-row omnigrid-row-group" : "omnigrid-row";
|
|
589
615
|
const rowParams = getRowRenderParams(row);
|
|
590
616
|
const currentOptions = current();
|
|
591
|
-
const rowClass = typeof currentOptions.rowClass === "function"
|
|
617
|
+
const rowClass = typeof currentOptions.rowClass === "function"
|
|
618
|
+
? currentOptions.rowClass(rowParams)
|
|
619
|
+
: currentOptions.rowClass;
|
|
592
620
|
const dynamicRowClass = currentOptions.getRowClass?.(rowParams);
|
|
593
621
|
const ruleClasses = Object.entries(currentOptions.rowClassRules ?? {})
|
|
594
622
|
.filter(([, predicate]) => predicate(rowParams))
|
|
@@ -609,8 +637,10 @@ export function OmniGrid({ className, style, slotComponents, cellTooltipRenderer
|
|
|
609
637
|
},
|
|
610
638
|
resolveCellClasses: (info) => {
|
|
611
639
|
const flashedCells = grid.getState().flashedCells;
|
|
612
|
-
const flashTimestamp = flashedCells.get(`${info.rowId}:${info.column.id}`);
|
|
613
|
-
const isFlashed = cellFlashDurationMs !== false &&
|
|
640
|
+
const flashTimestamp = info.column.cellFlash === false ? undefined : flashedCells.get(`${info.rowId}:${info.column.id}`);
|
|
641
|
+
const isFlashed = cellFlashDurationMs !== false &&
|
|
642
|
+
flashTimestamp !== undefined &&
|
|
643
|
+
Date.now() - flashTimestamp <= cellFlashDurationMs;
|
|
614
644
|
const cellParams = {
|
|
615
645
|
id: info.rowId,
|
|
616
646
|
index: info.rowIndex,
|
|
@@ -628,8 +658,10 @@ export function OmniGrid({ className, style, slotComponents, cellTooltipRenderer
|
|
|
628
658
|
},
|
|
629
659
|
resolveCellStyle: (info) => {
|
|
630
660
|
const flashedCells = grid.getState().flashedCells;
|
|
631
|
-
const flashTimestamp = flashedCells.get(`${info.rowId}:${info.column.id}`);
|
|
632
|
-
const isFlashed = cellFlashDurationMs !== false &&
|
|
661
|
+
const flashTimestamp = info.column.cellFlash === false ? undefined : flashedCells.get(`${info.rowId}:${info.column.id}`);
|
|
662
|
+
const isFlashed = cellFlashDurationMs !== false &&
|
|
663
|
+
flashTimestamp !== undefined &&
|
|
664
|
+
Date.now() - flashTimestamp <= cellFlashDurationMs;
|
|
633
665
|
const cellParams = {
|
|
634
666
|
id: info.rowId,
|
|
635
667
|
index: info.rowIndex,
|
|
@@ -767,7 +799,9 @@ export function OmniGrid({ className, style, slotComponents, cellTooltipRenderer
|
|
|
767
799
|
return;
|
|
768
800
|
const state = grid.getState();
|
|
769
801
|
const processed = getPoolData(grid);
|
|
770
|
-
const changed = layer.revision !== grid.getRevision() ||
|
|
802
|
+
const changed = layer.revision !== grid.getRevision() ||
|
|
803
|
+
layer.totalWidth !== viewportData.totalWidth ||
|
|
804
|
+
layer.processed !== processed;
|
|
771
805
|
if (changed) {
|
|
772
806
|
layer.revision = grid.getRevision();
|
|
773
807
|
layer.totalWidth = viewportData.totalWidth;
|
|
@@ -918,7 +952,7 @@ export function OmniGrid({ className, style, slotComponents, cellTooltipRenderer
|
|
|
918
952
|
const syncScrollbarInsets = useCallback((element) => {
|
|
919
953
|
const right = Math.max(0, element.offsetWidth - element.clientWidth - element.clientLeft * 2);
|
|
920
954
|
const bottom = Math.max(0, element.offsetHeight - element.clientHeight - element.clientTop * 2);
|
|
921
|
-
setScrollbarInsets((previous) =>
|
|
955
|
+
setScrollbarInsets((previous) => previous.right === right && previous.bottom === bottom ? previous : { right, bottom });
|
|
922
956
|
}, []);
|
|
923
957
|
const measureViewport = useCallback(() => {
|
|
924
958
|
const element = viewportRef.current;
|
|
@@ -1118,7 +1152,9 @@ export function OmniGrid({ className, style, slotComponents, cellTooltipRenderer
|
|
|
1118
1152
|
const groups = renderSlotGroups(mounts, context);
|
|
1119
1153
|
if (groups.every((group) => group === null))
|
|
1120
1154
|
return null;
|
|
1121
|
-
const slotClass = slot === "down"
|
|
1155
|
+
const slotClass = slot === "down"
|
|
1156
|
+
? "omnigrid-slot omnigrid-slot-bottom omnigrid-slot-down"
|
|
1157
|
+
: `omnigrid-slot omnigrid-slot-${slot}`;
|
|
1122
1158
|
return _jsx("div", { className: slotClass, children: groups });
|
|
1123
1159
|
};
|
|
1124
1160
|
/** Renders slots that overlay the table body (absolute positioning, no layout shift). */
|
|
@@ -1149,7 +1185,8 @@ export function OmniGrid({ className, style, slotComponents, cellTooltipRenderer
|
|
|
1149
1185
|
const registeredRenderer = typeof overlay.component === "string"
|
|
1150
1186
|
? optionsRef.current.overlayComponents?.[overlay.component]
|
|
1151
1187
|
: optionsRef.current.overlayComponents?.[overlay.type];
|
|
1152
|
-
const component = typeof overlay.component === "function" ||
|
|
1188
|
+
const component = typeof overlay.component === "function" ||
|
|
1189
|
+
(typeof overlay.component === "object" && overlay.component !== null)
|
|
1153
1190
|
? overlay.component
|
|
1154
1191
|
: registeredRenderer;
|
|
1155
1192
|
const isLegacyRenderer = typeof component === "function" && component.length >= 2;
|
|
@@ -1193,6 +1230,20 @@ export function OmniGrid({ className, style, slotComponents, cellTooltipRenderer
|
|
|
1193
1230
|
// correctly on the horizontal axis because sticky positioning is not
|
|
1194
1231
|
// affected by the clip.
|
|
1195
1232
|
const needsHorizontalScroll = viewportData.totalWidth > grid.getState().viewport.width;
|
|
1233
|
+
const renderHeaderExtensions = (item, position) => {
|
|
1234
|
+
const params = { column: item.column, index: item.index };
|
|
1235
|
+
return grid.getHeaderExtensions(position).map((extension) => {
|
|
1236
|
+
const content = contentToReactNode(extension.render(params), {
|
|
1237
|
+
registry: slotComponentsRef.current,
|
|
1238
|
+
context: buildRenderContext,
|
|
1239
|
+
});
|
|
1240
|
+
if (!hasRenderableContent(content))
|
|
1241
|
+
return null;
|
|
1242
|
+
const wrapper = position === "overlay" ? "div" : "span";
|
|
1243
|
+
const className = position === "overlay" ? "omnigrid-header-overlay-item" : "omnigrid-header-extension";
|
|
1244
|
+
return createElement(wrapper, { key: extension.id, className }, content);
|
|
1245
|
+
});
|
|
1246
|
+
};
|
|
1196
1247
|
const renderHeaderCells = (columns, originX) => columns.map((item) => {
|
|
1197
1248
|
const deepestDepth = hasGroups ? (viewportData.columnGroupDepth.get(item.index) ?? -1) : -1;
|
|
1198
1249
|
const gapRows = headerRowCount - 1 - deepestDepth;
|
|
@@ -1200,6 +1251,28 @@ export function OmniGrid({ className, style, slotComponents, cellTooltipRenderer
|
|
|
1200
1251
|
const headerParams = { column: item.column, index: item.index };
|
|
1201
1252
|
const className = resolveHeaderClasses(item.column, headerParams, fullHeight);
|
|
1202
1253
|
const customHeaderStyle = resolveHeaderStyle(item.column, headerParams);
|
|
1254
|
+
const headerAlign = item.column.headerAlign;
|
|
1255
|
+
const headerJustify = headerAlign === "center"
|
|
1256
|
+
? "center"
|
|
1257
|
+
: headerAlign === "right"
|
|
1258
|
+
? "flex-end"
|
|
1259
|
+
: headerAlign === "left"
|
|
1260
|
+
? "flex-start"
|
|
1261
|
+
: undefined;
|
|
1262
|
+
const headerStartExtensions = renderHeaderExtensions(item, "start");
|
|
1263
|
+
const headerEndExtensions = renderHeaderExtensions(item, "end");
|
|
1264
|
+
const headerOverlayExtensions = renderHeaderExtensions(item, "overlay");
|
|
1265
|
+
const hasFilterTrigger = grid.hasFilterMenu() && item.column.filterable !== false;
|
|
1266
|
+
const hasHeaderTools = Boolean(item.column.sortState) || hasFilterTrigger || headerEndExtensions.length > 0;
|
|
1267
|
+
const headerContent = item.column.headerRenderer
|
|
1268
|
+
? contentToReactNode(item.column.headerRenderer(item.column), {
|
|
1269
|
+
registry: slotComponentsRef.current,
|
|
1270
|
+
context: buildRenderContext,
|
|
1271
|
+
})
|
|
1272
|
+
: getGroupColumnRole(item.column, grid.getState().groupBy, grid.getState().groupColumnMode)
|
|
1273
|
+
.isGroupColumn && grid.getState().groupColumnMode === "single"
|
|
1274
|
+
? grid.getState().groupColumnHeader
|
|
1275
|
+
: (item.column.header ?? item.column.id);
|
|
1203
1276
|
const headerCellLayout = {
|
|
1204
1277
|
alignItems: "center",
|
|
1205
1278
|
display: "flex",
|
|
@@ -1216,31 +1289,44 @@ export function OmniGrid({ className, style, slotComponents, cellTooltipRenderer
|
|
|
1216
1289
|
visibility: isViewportMeasured ? undefined : "hidden",
|
|
1217
1290
|
width: item.width,
|
|
1218
1291
|
};
|
|
1219
|
-
|
|
1292
|
+
const headerContentLayout = {
|
|
1293
|
+
alignItems: "center",
|
|
1294
|
+
display: "flex",
|
|
1295
|
+
flex: "1 1 auto",
|
|
1296
|
+
justifyContent: headerJustify,
|
|
1297
|
+
minWidth: 0,
|
|
1298
|
+
overflow: "hidden",
|
|
1299
|
+
};
|
|
1300
|
+
return (_jsxs("div", { role: "columnheader", className: className, "data-sort": item.column.sortState, "data-sort-index": item.column.sortIndex, "data-sortable": item.column.sortable === true ? "true" : undefined, "aria-sort": item.column.sortState === "asc"
|
|
1301
|
+
? "ascending"
|
|
1302
|
+
: item.column.sortState === "desc"
|
|
1303
|
+
? "descending"
|
|
1304
|
+
: "none", onClick: (event) => item.column.stopHeaderClick
|
|
1220
1305
|
? event.stopPropagation()
|
|
1221
1306
|
: grid.headerClick(item.column.id, event.shiftKey || event.ctrlKey || event.metaKey), onKeyDown: (event) => {
|
|
1222
1307
|
if (event.key === "Enter" || event.key === " ")
|
|
1223
1308
|
grid.headerClick(item.column.id);
|
|
1224
|
-
}, tabIndex: 0, style: headerCellLayout, children:
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
}
|
|
1309
|
+
}, tabIndex: 0, style: headerCellLayout, children: [headerStartExtensions.length > 0 && (_jsx("span", { className: "omnigrid-header-start", children: headerStartExtensions })), _jsx("div", { className: "omnigrid-header-main", style: headerContentLayout, children: item.column.headerRenderer ? (headerContent) : (_jsx("span", { className: "omnigrid-header-label", style: {
|
|
1310
|
+
flex: "1 1 auto",
|
|
1311
|
+
minWidth: 0,
|
|
1312
|
+
textAlign: headerAlign ?? "left",
|
|
1313
|
+
}, children: headerContent })) }), hasHeaderTools && (_jsxs("span", { className: "omnigrid-header-tools", children: [item.column.sortState && (_jsxs("span", { className: "omnigrid-sort-indicator", "aria-hidden": "true", children: [contentToReactNode(item.column.sortState === "asc"
|
|
1314
|
+
? grid.icons.get("arrow-up")
|
|
1315
|
+
: grid.icons.get("arrow-down"), {
|
|
1316
|
+
registry: slotComponentsRef.current,
|
|
1317
|
+
context: buildRenderContext,
|
|
1318
|
+
}), item.column.sortIndex !== undefined && (_jsx("span", { className: "omnigrid-sort-priority", children: item.column.sortIndex }))] })), hasFilterTrigger && (_jsx("button", { type: "button", className: "omnigrid-filter-trigger", "data-omnigrid-filter-trigger": "", "data-active": isColumnFiltered(item.column) ? "true" : undefined, "aria-label": `Filter ${item.column.header ?? item.column.id}`, "aria-haspopup": "dialog", tabIndex: -1, onClick: (event) => {
|
|
1319
|
+
event.stopPropagation();
|
|
1320
|
+
const rect = event.currentTarget.getBoundingClientRect();
|
|
1321
|
+
const layoutRect = layoutRef.current?.getBoundingClientRect() ??
|
|
1322
|
+
{ left: 0, top: 0, width: 0, height: 0 };
|
|
1323
|
+
grid.requestFilterMenu(item.column.id, {
|
|
1324
|
+
x: rect.left - layoutRect.left,
|
|
1325
|
+
y: rect.top - layoutRect.top,
|
|
1326
|
+
width: rect.width,
|
|
1327
|
+
height: rect.height,
|
|
1328
|
+
});
|
|
1329
|
+
}, onKeyDown: (event) => event.stopPropagation(), children: _jsx("svg", { viewBox: "0 0 24 24", width: "12", height: "12", fill: "currentColor", "aria-hidden": "true", children: _jsx("path", { d: "M3 4h18l-7 8.5V20l-4-2v-5.5z" }) }) })), headerEndExtensions] })), headerOverlayExtensions.length > 0 && (_jsx("div", { className: "omnigrid-header-overlay", children: headerOverlayExtensions }))] }, item.column.id));
|
|
1244
1330
|
});
|
|
1245
1331
|
const renderGroupCells = (depth, columns, originX) => computeGroupSegments(viewportData.columnGroups, columns, depth, originX).map((segment, index) => {
|
|
1246
1332
|
const groupParams = {
|
|
@@ -1251,11 +1337,13 @@ export function OmniGrid({ className, style, slotComponents, cellTooltipRenderer
|
|
|
1251
1337
|
};
|
|
1252
1338
|
const className = resolveGroupHeaderClasses(segment.group, groupParams);
|
|
1253
1339
|
const customGroupStyle = resolveGroupHeaderStyle(segment.group, groupParams);
|
|
1340
|
+
const groupHeaderAlign = segment.group.headerAlign;
|
|
1341
|
+
const groupJustify = groupHeaderAlign === "left" ? "flex-start" : groupHeaderAlign === "right" ? "flex-end" : "center";
|
|
1254
1342
|
const groupCellLayout = {
|
|
1255
1343
|
alignItems: "center",
|
|
1256
1344
|
display: "flex",
|
|
1257
1345
|
fontWeight: 600,
|
|
1258
|
-
justifyContent:
|
|
1346
|
+
justifyContent: groupJustify,
|
|
1259
1347
|
overflow: "hidden",
|
|
1260
1348
|
padding: "0 12px",
|
|
1261
1349
|
whiteSpace: "nowrap",
|
|
@@ -1270,7 +1358,7 @@ export function OmniGrid({ className, style, slotComponents, cellTooltipRenderer
|
|
|
1270
1358
|
return (_jsx("div", { role: "columnheader", className: className, "aria-colspan": segment.columnCount, style: groupCellLayout, children: segment.group.headerRenderer ? (contentToReactNode(segment.group.headerRenderer(segment.group), {
|
|
1271
1359
|
registry: slotComponentsRef.current,
|
|
1272
1360
|
context: buildRenderContext,
|
|
1273
|
-
})) : (_jsx("span", { className: "omnigrid-header-label", children: segment.group.header ?? segment.group.id })) }, `${depth}:${index}:${segment.group.id}`));
|
|
1361
|
+
})) : (_jsx("span", { className: "omnigrid-header-label", style: { textAlign: groupHeaderAlign ?? "center" }, children: segment.group.header ?? segment.group.id })) }, `${depth}:${index}:${segment.group.id}`));
|
|
1274
1362
|
});
|
|
1275
1363
|
/**
|
|
1276
1364
|
* Sticky header stack: `headerRowCount` group rows (one per depth) above the
|
|
@@ -1323,7 +1411,11 @@ export function OmniGrid({ className, style, slotComponents, cellTooltipRenderer
|
|
|
1323
1411
|
height: autoHeight ? measuredHeight : "100%",
|
|
1324
1412
|
minHeight: minViewportHeight,
|
|
1325
1413
|
minWidth: 0,
|
|
1326
|
-
overflowX: overlayBlocksHorizontalScroll
|
|
1414
|
+
overflowX: overlayBlocksHorizontalScroll
|
|
1415
|
+
? "hidden"
|
|
1416
|
+
: needsHorizontalScroll
|
|
1417
|
+
? "auto"
|
|
1418
|
+
: "hidden",
|
|
1327
1419
|
overflowY: overlayScope || autoHeight ? "hidden" : "auto",
|
|
1328
1420
|
position: "relative",
|
|
1329
1421
|
scrollbarGutter: verticalScrollbarGutter,
|
|
@@ -1362,5 +1454,5 @@ export function OmniGrid({ className, style, slotComponents, cellTooltipRenderer
|
|
|
1362
1454
|
top: headerHeight,
|
|
1363
1455
|
width: "100%",
|
|
1364
1456
|
zIndex: 4,
|
|
1365
|
-
}, children: renderOverlayContent(overlayState) }))] }), renderSlot("right")] }), renderSlot("bottom"), _jsx(PopupHost, { grid: grid }), _jsx(CellTooltipLayer, { viewportRef: viewportRef, renderer: cellTooltipRenderer, className: cellTooltipClassName }), overlayState.type && isFullOverlay && (_jsx("div", { className: "omnigrid-overlay omnigrid-overlay-full", role: "status", children: renderOverlayContent(overlayState) }))] }));
|
|
1457
|
+
}, children: renderOverlayContent(overlayState) }))] }), renderSlot("right")] }), renderSlot("bottom"), _jsx(PopupHost, { grid: grid }), _jsx(CellTooltipLayer, { viewportRef: viewportRef, renderer: cellTooltipRenderer, className: cellTooltipClassName, resolveCellTooltip: (columnId) => columnTooltipOptions.get(columnId) }), overlayState.type && isFullOverlay && (_jsx("div", { className: "omnigrid-overlay omnigrid-overlay-full", role: "status", children: renderOverlayContent(overlayState) }))] }));
|
|
1366
1458
|
}
|
package/dist/cellTooltip.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { type ReactNode, type RefObject } from "react";
|
|
2
|
-
import type { CellTooltipRenderer } from "./
|
|
2
|
+
import type { CellTooltipRenderer } from "./reactColumnDef";
|
|
3
|
+
import type { CellTooltipOptions } from "./types";
|
|
4
|
+
export declare function isTextOverflowed(textWidth: number, containerWidth: number): boolean;
|
|
3
5
|
/** Props for the delegated tooltip layer mounted by the grid. */
|
|
4
6
|
export interface CellTooltipLayerProps {
|
|
5
7
|
/** Viewport whose cell and header descendants are checked on pointer entry. */
|
|
@@ -8,6 +10,8 @@ export interface CellTooltipLayerProps {
|
|
|
8
10
|
renderer?: CellTooltipRenderer;
|
|
9
11
|
/** Additional CSS class applied to the tooltip element. */
|
|
10
12
|
className?: string;
|
|
13
|
+
/** Resolves per-column tooltip overrides for hovered data cells. */
|
|
14
|
+
resolveCellTooltip?: (columnId: string) => CellTooltipOptions | undefined;
|
|
11
15
|
}
|
|
12
16
|
/** Displays a tooltip only when hovered cell or header content exceeds its visible bounds. */
|
|
13
|
-
export declare function CellTooltipLayer({ viewportRef, renderer, className }: CellTooltipLayerProps): ReactNode;
|
|
17
|
+
export declare function CellTooltipLayer({ viewportRef, renderer, className, resolveCellTooltip }: CellTooltipLayerProps): ReactNode;
|
package/dist/cellTooltip.js
CHANGED
|
@@ -8,16 +8,21 @@ function isOverflowed(element) {
|
|
|
8
8
|
return false;
|
|
9
9
|
const range = document.createRange();
|
|
10
10
|
range.selectNodeContents(element);
|
|
11
|
-
return range.getBoundingClientRect().width
|
|
11
|
+
return isTextOverflowed(range.getBoundingClientRect().width, element.getBoundingClientRect().width);
|
|
12
|
+
}
|
|
13
|
+
export function isTextOverflowed(textWidth, containerWidth) {
|
|
14
|
+
return textWidth - containerWidth > 1;
|
|
12
15
|
}
|
|
13
16
|
/** Displays a tooltip only when hovered cell or header content exceeds its visible bounds. */
|
|
14
|
-
export function CellTooltipLayer({ viewportRef, renderer, className }) {
|
|
17
|
+
export function CellTooltipLayer({ viewportRef, renderer, className, resolveCellTooltip }) {
|
|
15
18
|
const [tooltip, setTooltip] = useState(null);
|
|
16
19
|
const tooltipRef = useRef(null);
|
|
17
20
|
const rendererRef = useRef(renderer);
|
|
18
21
|
const classNameRef = useRef(className);
|
|
22
|
+
const resolveCellTooltipRef = useRef(resolveCellTooltip);
|
|
19
23
|
rendererRef.current = renderer;
|
|
20
24
|
classNameRef.current = className;
|
|
25
|
+
resolveCellTooltipRef.current = resolveCellTooltip;
|
|
21
26
|
useEffect(() => {
|
|
22
27
|
const viewport = viewportRef.current;
|
|
23
28
|
if (!viewport)
|
|
@@ -68,7 +73,17 @@ export function CellTooltipLayer({ viewportRef, renderer, className }) {
|
|
|
68
73
|
const rect = overflowTarget.getBoundingClientRect();
|
|
69
74
|
activeContainer = container;
|
|
70
75
|
activeHoverTarget = overflowTarget;
|
|
71
|
-
|
|
76
|
+
const columnTooltip = isCell && container.dataset.columnId ? resolveCellTooltipRef.current?.(container.dataset.columnId) : undefined;
|
|
77
|
+
setTooltip({
|
|
78
|
+
text,
|
|
79
|
+
anchorRect: rect,
|
|
80
|
+
pointer: { clientX: event.clientX, clientY: event.clientY },
|
|
81
|
+
source: isCell ? "cell" : "header",
|
|
82
|
+
columnId: isCell ? container.dataset.columnId : undefined,
|
|
83
|
+
placement: "bottom",
|
|
84
|
+
renderer: columnTooltip?.renderer ?? rendererRef.current,
|
|
85
|
+
className: columnTooltip?.className ?? classNameRef.current,
|
|
86
|
+
});
|
|
72
87
|
};
|
|
73
88
|
const handlePointerOut = (event) => {
|
|
74
89
|
if (!activeContainer || !(event.target instanceof Node) || !activeContainer.contains(event.target))
|
|
@@ -95,15 +110,30 @@ export function CellTooltipLayer({ viewportRef, renderer, className }) {
|
|
|
95
110
|
if (!element || !tooltip)
|
|
96
111
|
return;
|
|
97
112
|
const rect = element.getBoundingClientRect();
|
|
98
|
-
const left = Math.max(8, Math.min(tooltip.left, window.innerWidth - rect.width - 8));
|
|
99
|
-
const belowTop = tooltip.
|
|
100
|
-
const
|
|
113
|
+
const left = Math.max(8, Math.min(tooltip.anchorRect.left, window.innerWidth - rect.width - 8));
|
|
114
|
+
const belowTop = tooltip.anchorRect.bottom + 6;
|
|
115
|
+
const placement = belowTop + rect.height <= window.innerHeight - 8 ? "bottom" : "top";
|
|
116
|
+
const top = placement === "bottom" ? belowTop : Math.max(8, tooltip.anchorRect.top - rect.height - 6);
|
|
101
117
|
element.style.left = `${left}px`;
|
|
102
118
|
element.style.top = `${top}px`;
|
|
119
|
+
element.dataset.placement = placement;
|
|
120
|
+
const arrowX = tooltip.pointer?.clientX ?? tooltip.anchorRect.left + tooltip.anchorRect.width / 2;
|
|
121
|
+
element.style.setProperty("--omnigrid-tooltip-arrow-x", `${Math.max(8, Math.min(arrowX - left, rect.width - 8))}px`);
|
|
122
|
+
element.style.setProperty("--omnigrid-tooltip-arrow-y", placement === "bottom" ? "0px" : `${rect.height}px`);
|
|
123
|
+
if (tooltip.placement !== placement) {
|
|
124
|
+
setTooltip((current) => (current === tooltip ? { ...current, placement } : current));
|
|
125
|
+
}
|
|
103
126
|
}, [tooltip]);
|
|
104
127
|
if (!tooltip)
|
|
105
128
|
return null;
|
|
106
|
-
const
|
|
107
|
-
|
|
129
|
+
const renderContext = {
|
|
130
|
+
anchorRect: tooltip.anchorRect,
|
|
131
|
+
pointer: tooltip.pointer,
|
|
132
|
+
source: tooltip.source,
|
|
133
|
+
columnId: tooltip.columnId,
|
|
134
|
+
placement: tooltip.placement,
|
|
135
|
+
};
|
|
136
|
+
const content = tooltip.renderer ? tooltip.renderer(tooltip.text, renderContext) : tooltip.text;
|
|
137
|
+
const tooltipClassName = ["omnigrid-cell-tooltip", tooltip.className].filter(Boolean).join(" ");
|
|
108
138
|
return createPortal(_jsx("div", { ref: tooltipRef, className: tooltipClassName, role: "tooltip", style: { left: 0, top: 0 }, children: content }), document.body);
|
|
109
139
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import "@omnigrid/style";
|
|
2
2
|
import "@omnigrid/default-theme";
|
|
3
3
|
export * from "@omnigrid/core";
|
|
4
|
-
export type { ReactCellRenderer, ReactColumnDef, ReactColumnDef as ColumnDef, ReactColumnGroupDef, ReactColumnGroupDef as ColumnGroupDef, ReactColumnLeafDef, ReactColumnLeafDef as ColumnLeafDef, ReactGridOptions, ReactGridOptions as GridOptions, } from "./reactColumnDef";
|
|
4
|
+
export type { CellTooltipRenderer, CellTooltipRenderContext, ReactCellRenderer, ReactColumnDef, ReactColumnDef as ColumnDef, ReactColumnGroupDef, ReactColumnGroupDef as ColumnGroupDef, ReactColumnLeafDef, ReactColumnLeafDef as ColumnLeafDef, ReactGridOptions, ReactGridOptions as GridOptions, } from "./reactColumnDef";
|
|
5
5
|
export { PooledRowPane } from "./pooledRow";
|
|
6
6
|
export type { ContentBridge, PooledCellRenderInfo, PooledColumn, PooledRowCallbacks, PooledRowModifiers } from "./types";
|
|
7
7
|
export { OmniGrid } from "./OmniGrid";
|
|
8
|
-
export type {
|
|
8
|
+
export type { GridProps, OverlayComponent, OverlayComponentProps, SlotRendererRegistry } from "./types";
|
|
9
9
|
export { useGrid } from "./useGrid";
|
|
10
10
|
export { DebouncedInput, isUIControlDescriptor, renderControl } from "./controls";
|
|
11
11
|
export type { DebouncedInputProps } from "./controls";
|
package/dist/pooledRow.js
CHANGED
|
@@ -358,6 +358,7 @@ export class PooledRowPane {
|
|
|
358
358
|
cell.appliedStyleKeys.push(key);
|
|
359
359
|
}
|
|
360
360
|
}
|
|
361
|
+
cell.element.dataset.columnId = cellInfo.column.id;
|
|
361
362
|
const flushLayout = cellInfo.column.cellLayout === "flush";
|
|
362
363
|
if (flushLayout)
|
|
363
364
|
cell.element.style.padding = "0";
|
package/dist/popup.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
2
|
import type { PopupHostProps } from "./types";
|
|
3
|
+
export declare function clampPopupLeft(desiredLeft: number, popupWidth: number, minLeft: number, maxRight: number): number;
|
|
3
4
|
/**
|
|
4
5
|
* Renders the grid's active `UIPopupDescriptor`. Popup state lives here, so
|
|
5
6
|
* opening or updating a popup never re-renders the grid body. The popup is
|
package/dist/popup.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { createElement, useEffect, useLayoutEffect, useRef, useState } from "react";
|
|
2
2
|
import { contentToReactNode } from "./content";
|
|
3
3
|
const VIEWPORT_MARGIN = 8;
|
|
4
|
+
export function clampPopupLeft(desiredLeft, popupWidth, minLeft, maxRight) {
|
|
5
|
+
const maxLeft = Math.max(minLeft, maxRight - popupWidth);
|
|
6
|
+
return Math.min(Math.max(desiredLeft, minLeft), maxLeft);
|
|
7
|
+
}
|
|
4
8
|
function anchorStyle(popup) {
|
|
5
9
|
const base = { position: "absolute", zIndex: 1000 };
|
|
6
10
|
const anchor = popup.anchor;
|
|
@@ -49,20 +53,25 @@ export function PopupHost({ grid }) {
|
|
|
49
53
|
document.removeEventListener("keydown", handleKeyDown);
|
|
50
54
|
};
|
|
51
55
|
}, [grid, isOpen, closeOnOutside, closeOnEscape]);
|
|
52
|
-
// Keep an anchored popup inside the
|
|
56
|
+
// Keep an anchored popup inside both the grid and the visible window.
|
|
53
57
|
useLayoutEffect(() => {
|
|
54
58
|
const element = elementRef.current;
|
|
55
59
|
if (!element || !popup?.anchor)
|
|
56
60
|
return;
|
|
57
|
-
const rect = element.getBoundingClientRect();
|
|
58
61
|
const parent = element.parentElement;
|
|
59
|
-
const parentRect = parent
|
|
60
|
-
const
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
62
|
+
const parentRect = parent?.getBoundingClientRect() ?? null;
|
|
63
|
+
const parentLeft = parentRect?.left ?? 0;
|
|
64
|
+
const minLeft = Math.max(VIEWPORT_MARGIN, parentLeft + VIEWPORT_MARGIN);
|
|
65
|
+
const maxRight = Math.min(window.innerWidth - VIEWPORT_MARGIN, (parentRect?.right ?? window.innerWidth) - VIEWPORT_MARGIN);
|
|
66
|
+
const availableWidth = Math.max(0, maxRight - minLeft);
|
|
67
|
+
element.style.maxWidth = `${availableWidth}px`;
|
|
68
|
+
element.style.minWidth = `${Math.min(200, availableWidth)}px`;
|
|
69
|
+
const rect = element.getBoundingClientRect();
|
|
70
|
+
const anchorLeft = parentLeft + popup.anchor.x;
|
|
71
|
+
const desiredLeft = popup.placement === "bottom-end" ? anchorLeft + (popup.anchor.width ?? 0) - rect.width : anchorLeft;
|
|
72
|
+
const left = clampPopupLeft(desiredLeft, rect.width, minLeft, maxRight);
|
|
73
|
+
element.style.transform = "none";
|
|
74
|
+
element.style.left = `${left - parentLeft}px`;
|
|
66
75
|
}, [popup]);
|
|
67
76
|
if (!popup)
|
|
68
77
|
return null;
|
package/dist/reactColumnDef.d.ts
CHANGED
|
@@ -6,6 +6,32 @@ import type { CellRenderParams, ColumnGroupDef, ColumnLeafDef, GridOptions } fro
|
|
|
6
6
|
* @api
|
|
7
7
|
*/
|
|
8
8
|
export type ReactCellRenderer<T> = (params: CellRenderParams<T>) => ReactNode;
|
|
9
|
+
/**
|
|
10
|
+
* Context supplied to a custom cell or header tooltip renderer.
|
|
11
|
+
*
|
|
12
|
+
* @api
|
|
13
|
+
*/
|
|
14
|
+
export interface CellTooltipRenderContext {
|
|
15
|
+
/** Bounds of the truncated text or header label in viewport coordinates. */
|
|
16
|
+
anchorRect: DOMRectReadOnly;
|
|
17
|
+
/** Pointer position in viewport coordinates, or `null` when unavailable. */
|
|
18
|
+
pointer: {
|
|
19
|
+
clientX: number;
|
|
20
|
+
clientY: number;
|
|
21
|
+
} | null;
|
|
22
|
+
/** Whether the truncated content belongs to a data cell or a header. */
|
|
23
|
+
source: "cell" | "header";
|
|
24
|
+
/** Column identifier for data cells; group headers may not have one. */
|
|
25
|
+
columnId?: string;
|
|
26
|
+
/** Side of the anchor where the tooltip is displayed after viewport collision handling. */
|
|
27
|
+
placement: "top" | "bottom";
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Renders the full text of a truncated cell or header in its hover tooltip.
|
|
31
|
+
*
|
|
32
|
+
* @api
|
|
33
|
+
*/
|
|
34
|
+
export type CellTooltipRenderer = (text: string, context?: CellTooltipRenderContext) => ReactNode;
|
|
9
35
|
/**
|
|
10
36
|
* Leaf column definition with a renderer typed for React content.
|
|
11
37
|
*
|
|
@@ -14,6 +40,10 @@ export type ReactCellRenderer<T> = (params: CellRenderParams<T>) => ReactNode;
|
|
|
14
40
|
export type ReactColumnLeafDef<T> = Omit<ColumnLeafDef<T>, "cellRenderer"> & {
|
|
15
41
|
/** Replaces the default cell content with a React node. */
|
|
16
42
|
cellRenderer?: ReactCellRenderer<T>;
|
|
43
|
+
/** Overrides the grid-level renderer for this column's truncated cell content. */
|
|
44
|
+
cellTooltipRenderer?: CellTooltipRenderer;
|
|
45
|
+
/** Overrides the grid-level class for this column's truncated cell tooltip. */
|
|
46
|
+
cellTooltipClassName?: string;
|
|
17
47
|
};
|
|
18
48
|
/**
|
|
19
49
|
* Column group definition whose children use React-specific column types.
|
package/dist/types.d.ts
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
2
|
import type { SlotRenderContext, UIInputControl } from "@omnigrid/core";
|
|
3
3
|
import type { CellRoot } from "./reactRoot";
|
|
4
|
-
import type { ReactGridOptions } from "./reactColumnDef";
|
|
4
|
+
import type { CellTooltipRenderer, ReactGridOptions } from "./reactColumnDef";
|
|
5
|
+
/** Tooltip overrides resolved for a particular data column. */
|
|
6
|
+
export interface CellTooltipOptions {
|
|
7
|
+
/** Custom renderer for the truncated cell's full text. */
|
|
8
|
+
renderer?: CellTooltipRenderer;
|
|
9
|
+
/** Additional class applied to the tooltip element. */
|
|
10
|
+
className?: string;
|
|
11
|
+
}
|
|
5
12
|
/**
|
|
6
13
|
* Bridge between the core's headless content and native adapter values.
|
|
7
14
|
* `registry` — registry of React components for `SlotComponentContent`;
|
|
@@ -78,12 +85,6 @@ export interface SlotRendererRegistry<T> {
|
|
|
78
85
|
}
|
|
79
86
|
export type OverlayComponentProps<T> = import("@omnigrid/core").OverlayComponentProps<T>;
|
|
80
87
|
export type OverlayComponent<T> = import("react").ComponentType<import("@omnigrid/core").OverlayComponentProps<T>> | import("@omnigrid/core").OverlayComponent<T>;
|
|
81
|
-
/**
|
|
82
|
-
* Renders the full text of a truncated cell or header in its hover tooltip.
|
|
83
|
-
*
|
|
84
|
-
* @api
|
|
85
|
-
*/
|
|
86
|
-
export type CellTooltipRenderer = (text: string) => ReactNode;
|
|
87
88
|
export interface GridProps<T> extends Omit<ReactGridOptions<T>, "overlayComponents"> {
|
|
88
89
|
className?: string;
|
|
89
90
|
style?: import("react").CSSProperties;
|